Hi there,
I am very, very new to programming and need to work out how to determine if a number entered by a user is a prime number. I have coded this but it does not work. :'(
Any assistance would be greatly appreciated!
I also get the following error even though I do have a main method;
java.lang.NoSuchMethodError: main
Exception in thread "main" Java Result: 1
public static void primeNumberChecker()
{
Scanner keyboard = new Scanner(System.in);
int inputInt;
int number = 0;
int factor = 0;
double highestPossibleFactor = Math.sqrt(number);
int i;
System.out.println("Enter an integer value: ");
Scanner console = new Scanner (System.in);
number = console.nextInt();
for (i=2; i < number ;i++ ){
int n = number%i;
if (n==0){
System.out.println("not Prime!");
break;
}
}
if(i == number){
System.out.println("Prime number!");
}
}
}
public static void main(String[] args)
{
primeNumberChecker();
}
}