在我的计算机科学课上,我们被要求创建一个程序,该程序会提示用户输入他们希望在“魔术盒”中打印的行数、列数和符号,并存储这些变量中的每一个并将它们打印出来使用嵌套的 for 循环拥有自己的魔法盒。我的程序可以正确编译并根据我的输入打印正确的框,但它不会打印我的两个打印语句。它将打印前三个语句(提示用户输入某些内容的语句),但不打印语句
Here comes the magic...Here's your very own magic box
和
This magic box brought to you by Beth Tanner."
我已经尝试了我能想到的一切,但仍然无法打印这些语句,任何帮助将不胜感激。我在下面包括我的程序。
import java.util.Scanner;
public class MagicBox {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.println("How many rows would you like in your box?");
int rows = input.nextInt();
System.out.println("How many columns would you like in your box?");
int columns = input.nextInt();
System.out.println("What symbol would you like in your box?");
String symbol = input.next();
System.out.println("Here comes the magic...\nHere's your very own magic box!");
int count1;
int count2;
for(count1 = 1; count1 <= rows; count1++)
for (count2 = 1; count2 <= columns; count2++)
System.out.print(symbol);
System.out.println();
System.out.println("This magic box brought to you by Beth Tanner.");
} // end main
} // end class