0
A program that displays all the numbers from 100 to 200 that are divisible by 5 or 6, but not both
3 odpowiedzi
+ 7
take a look at the logical XOR operator (^)
https://stackoverflow.com/questions/726652/creating-a-logical-exclusive-or-operator-in-java
would be really helpful for that code you wrote
+ 1
in addition to above answer use continue statement in the first for loop
0
public class Program
{
public static void main(String[] args) {
for(int i=100;i<200;i++){
if((i%5==0)&&(i%6==0))
{System.out.println();}
if((i%5==0)||(i%6==0))
{System.out.print(i+ " ");}
}
}
}