我正在接受行和列的整數值,然後是字符的字符串值。如果用戶對於以字符「@」的列進入的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