我正在接受行和列的整数值,然后是字符的字符串值。如果用户对于以字符“@”的列进入的5行和2的值输出到用户应该是:创建具有行,列和字符输入的形状以填充形状的问题
@@
@@
@@
@@
@@
我到目前为止的代码如下,这里的评论是,在这里我似乎无法得到的循环努力创造与T形他使用输入的字符为所需的行数和列数输入。
import java.util.*;
public class createAShape
{
public static void main(String [] args)
{
Scanner in = new Scanner(System.in);
String errorMessage = "Please enter an amount in the range 1 and 25", result = "";
System.out.print("Enter number of rows: ");
int r = Integer.parseInt(in.nextLine());
if(r < 1 || r > 25)
System.out.println(errorMessage);
else
{
System.out.print("Enter number of columns: ");
int c = Integer.parseInt(in.nextLine());
if(c < 1 || c > 25)
System.out.println(errorMessage);
else
{
System.out.print("Enter symbol to use: ");
String character = in.nextLine();
//continuing from here
}
}
System.out.println(result);
}
}
其中*是*你的循环?如果您没有显示无法使用的代码,我们无法帮助您更正代码 – 2014-10-28 11:46:56