java 输出空行_在Java中,如何为每第5行打印一个空行?

这是基本的编程,但我仍然不完全确定如何创建一个空行每隔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你可以看看我的解决方案。 –

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值