public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int nextPrime = 2; //first prime
		int n = 1; //sequential number of a prime number
		System.out.printf("%d. prime number is %d\n\n", n, nextPrime);
		while (true) {

			System.out.print("Do you want to continue(y/n)? "); //user input
			String check = sc.nextLine();
			if (check.equals("y")) {

				boolean isPrime = false;
				while (!isPrime) {
					boolean primeCheck = true;
					nextPrime++;
					inner: for (int i = 2; i <= nextPrime / 2; i++) { //loop for checking if a number is prime
						if (nextPrime % i == 0) {
							primeCheck = false;
							break inner;
						}
					}
					if (primeCheck) {
						isPrime = true;
						n++;
					}
				}
				System.out.printf("%d. prime number is %d\n\n", n, nextPrime);
			} else {
				System.exit(0);
			}
		}
	}