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中'%'運算符的作用嗎? –