Hi guys - I need to write a program that reads in a user-input integer and tells if the number is prime or not. I've written up this code so far:
class primenumber
{
public static void main(String[] args){
int num = 10;
int i;
for (i=2; i < num ;i++){
int n = num%i;
if (n==0){
System.out.println("Your number is not a prime number.");
break;
}
}
if (i == num){
System.out.println("Your number is a prime number!");
}
}
}
I can tell if a number is prime or not if I assign num in the code, but I am having some trouble/confusion integrating this with prompting the user to enter an integer. Any help would be much appreciated.