i only really just started a java course, the task we have been set is to write a code that will output whether a number is prime or not.
public class PrimeNumbers2 {
public static void main(String[] args) {
int number = 9;
int count = 2;
Boolean prime = true;
if (number % count == 0) {
prime = true;
}
else {
for (count = count + 1) {
if (count + 1>= number) {
prime = false;
}
else
{
prime = false;
}
}
if (prime == true)
{
System.out.println("Number is prime");
}
else
{
System.out.println("number is not prime");
}
}}}
This is what I have come up with so far, but comes up with a lot of errors, i have searched for a lot of answers but they all say to use code lines that we haven't learnt about before, any help would be appreciated
Aucun commentaire:
Enregistrer un commentaire