Hi, I had to make a java coding that will determine if a number is a prime number or not. Here's the coding I did:
import.java.util.Scanner;
public class PrimeNumber
{
public static void main(String args[])
{
int n;
Scanner Prime = new Scanner(System.in);
System.out.println(" Please enter a number: ");
n = Prime.nextInt();
System.out.println(isPrime(n));
}
static boolean isPrime(int n) {
if (n%2==0) return false;
for(int i=3;i*i<=n;i+=2) {
if(n%i==0)
return false;
}
return true;
}
}
And I got just 1 more error to correct here:
PrimeNumber.java:1: error: <identifier> expected
import.java.util.Scanner;
^
1 error
Can anyone please shed some light on correcting this 1 error in my java coding here? Thanks in advance!