这是基本的编程,但我仍然不完全确定如何创建一个空行每隔5行。请帮忙!谢谢!在Java中,如何为每第5行打印一个空行?
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("please enter an integer for the length");
int theLength = input.nextInt();
System.out.println("Please enter an integer for the height");
int theHeight = input.nextInt();
System.out.println("Please enter a character");
String character1 = input.next();
// int character = Integer.toString(character1);
for (int i = 0; i < theHeight; i++) { //the outer loop controls the row
for (int j = 0; j < theLength; j++) {// inner loop control
if (j % 6 != 0) { //creates a space for ever 5 character
System.out.print(character1 + " ");
} else System.out.print(" ");
}
System.out.println();
}
}
2016-03-16
Paula
+2
目前还不清楚你问这里。请提供预期与实际产出,您遇到的具体问题以及您的问题的**明确**描述。 –
+0
目前尚不清楚您是否试图在每五排或每六排创建一个空间。 –
+0
@Paula你可以看看我的解决方案。 –