【发布时间】:2015-10-25 05:07:54
【问题描述】:
我无法弄清楚为什么我的 if-else 语句不能正常工作。这是我目前所拥有的:
import java.util.Scanner;
public class multiple {
public static void main (String[] args){
Scanner input = new Scanner (System.in);
int x = 4;
int y = 3;
int multiple = y % x;
while (multiple != 0){
System.out.println("Enter two integers: ");
x = input.nextInt();
y = input.nextInt();
if (multiple != 0)
System.out.println("Oops, sorry! The second integer is NOT a multiple of the first integer.");
else
System.out.println("Good Job! " + y + " is a multiple of " + x + "!");
}
}
}
【问题讨论】:
标签: java if-statement modulo