Hello,
Could you please run this?
I except show "Enter N:" but the program waiting to receive the number.
import java.util.Scanner; public class NewMain { public static boolean isPrime(int n) { boolean flag = true; for(int i = 2 ; i < n ; i++) { if (n %i == 0) { flag = false; break; } } return flag; } public static void Range(int a , int b) { for (int i = a ; i <=b ; i++) { if (!isPrime(i)) { System.out.printf("\n%d is NOT Prime!",i); } else { System.out.printf("\n%d is Prime!",i); } } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.printf("Enter N: "); // I except show this FIRST int n = scan.nextInt(); // But this run FIRST! boolean flag = isPrime(n); if (!flag) { System.out.printf("\n%d is NOT Prime!",n); } else { System.out.printf("\n%d is Prime!",n); } System.out.printf("Enter A: "); int a = scan.nextInt(); System.out.printf("Enter B: "); int b = scan.nextInt(); Range(a,b); } }