1
我想让我的程序每次plof变量都可以分割时写出“plof”一词。 所以:假设用户输入是可变plof = 3 我想采写:1 2 3 plof 4 5 6 plof 7 8 9 plof打印每一个字plof
public static void main(String[] args) {
Scanner invoer = new Scanner(System.in);
System.out.print("Wat is het \"plof\" getal? (2..9)");
int plof = invoer.nextInt();
System.out.print("Tot en met welk getal moet ik tellen?");
int telGetal = invoer.nextInt();
for(int i=0; i<= telGetal; i++) {
System.out.print(" "+i);
}
System.out.println(" ");
}
你知道Java中'%'运算符的作用吗? –