I need help with this program Write a program that displays all the numbers from
ID: 3672107 • Letter: I
Question
I need help with this program
Write a program that displays all the numbers from 100 to 200, ten per line, that are divisible by 5 or 6, but not both. Numbers are separated by exactly one space. Design the program such it allows the user to re-run the program with a different inputs (that is, the beginning and ending values such as 100 to 200) in the same run. Document your code, and organize and space the outputs as specified. Use escape characters and formatting objects when applicable.
This is what I have but it gives me an error DivisibleBy5And6.java:33: error: ';' expected
while( (a <= b))
import java.util.Scanner;
public class DivisibleBy5And6
{
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);
int count = 0,a,b;
System.out.println ("Enter a min and max number to calculate the numbers divisible by 5 or 6 not both: ");
a = input.nextInt();
b = input.nextInt();
while(a <= b)
{
if (count < 10)
if ((a%5 == 0 && a%6 != 0) || (a%5 != 0 && a%6 == 0))
{
System.out.print (a + " ");
count++;
}
if (count == 10)
{
System.out.println();
count = 0;
}
}
}
}
Explanation / Answer
Please find the corrected code below :