28,888 views
20 votes
20 votes
JAVA

plzzz help...........​

JAVA plzzz help...........​-example-1
User Neurix
by
2.9k points

1 Answer

12 votes
12 votes

Answer:

import java.util.Scanner;

class Main {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

while(true) {

System.out.print("Enter an integer (0 to exit): ");

int num = scan.nextInt();

if (num == 0) break;

if (num%3 == 0 && num%5 == 0) {

System.out.printf("%d is divisable by both 3 and 5.\\", num);

}

else if (num%3 == 0 && num%5 != 0) {

System.out.printf("%d is divisable by 3 but not by 5.\\", num);

}

else if (num%3 != 0 && num%5 == 0) {

System.out.printf("%d is divisable by 5 but not by 3.\\", num);

} else {

System.out.printf("%d is not divisable by 3 or 5.\\", num);

}

}

scan.close();

}

}

User Conrad Lotz
by
3.2k points