340,721 views
1 vote
1 vote
Rewrite the following using if else statement:

int x;
String s=(x%3=0)? “Divisible by 3" : "Not divisible by 3";
System.out.println(s);​

User PySaad
by
2.9k points

1 Answer

6 votes
6 votes
int x;
String s = “x%3=0?”
if( x%3 == 0){
s = “Divisible by 3”
}
else{
s = “Not divisible by 3”
}
System.out.println(s)
User Rheinprinz
by
2.7k points