0
What is wrong in the following program?
public class PrimeCheck { public static void main(String[] args) { Scannerin=newScanner(System.in); int n,i,c=0; System.out.println("Enter a number:"); n=in.nextInt(); for (i=1; i<=n; i++) { if(n%i==0) c++; } if(c==2) { System.out.println("A Prime Number!"); } else { System.out.println("Not a Prime Number!"); } } }
4 ответов
+ 12
Scannerin = new Scanner(System.in);
Replace with
Scanner in = new Scanner(System.in);
And you done
0
what error do you get?
0
import java.util.Scanner;
public class PrimeCheck
// ...
Scanner in = new Scanner(System.in); //add two spaces
0
give space in the scanner line between scanner and in