Here's a Java program that prompts the user for a positive integer, checks if it is a prime number, and continues looping until the user enters "exit":
```java
import java.util.Scanner;
public class PrimeNumberChecker {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input;
do {
System.out.print("Enter a positive integer (or 'exit' to quit): ");
input = scanner.nextLine();
if (!input.equalsIgnoreCase("exit")) {
try {
int number = Integer.parseInt(input);
String result = checkPrimeNumber(number);
System.out.println(result);
} catch (NumberFormatException e) {
System.out.println("Invalid input. Please enter a positive integer.");
}
System.out.println();
}
} while (!input.equalsIgnoreCase("exit"));
scanner.close();
}
public static String checkPrimeNumber(int number) {
if (number <= 1) {
return "The number is not prime.";
}
for (int i = 2; i <= Math.sqrt(number); i++) {
if (number % i == 0) {
return "The number is not prime.";
}
}
return "The number is prime.";
}
}
```
In this program, the `main` method prompts the user for a positive integer (or "exit" to quit) inside a `do-while` loop. If the user enters a value other than "exit", it attempts to parse the input as an integer using `Integer.parseInt()`. If the parsing is successful, it calls the `checkPrimeNumber` method to check if the number is prime and prints the corresponding message. If the parsing fails, it catches the `NumberFormatException` and informs the user about invalid input.
The `checkPrimeNumber` method takes an integer as input and checks if it is a prime number. It first checks if the number is less than or equal to 1, in which case it is not prime. Then, it uses a `for` loop to check if the number is divisible by any potential factors up to the square root of the number. If it is divisible, the method returns the message "The number is not prime." Otherwise, it returns the message "The number is prime."
The program continues to loop until the user enters "exit", at which point it exits the program.