Right now, when I get "Would you like to continue", if I press y (or Y), the program will just reprint the previous typed in value with the same question afterwards. How can I solve this? Thank you.
class PrimeNumber {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int value = 0;
char choice = 0;
do {
System.out.println("Enter integer ");
value = console.nextInt();
for (int i = 2; i < value; i++) {
if (value % i == 0) { // checks if value is evenly divisible by any number
System.out.println(value + " is not a prime number ");
} else {
System.out.println(value + " is a prime number ");
}
System.out.print("Would you like to continue y/n ");
choice = console.next().charAt(0);
}
} while (choice == 'y' || choice == 'Y');
}
}