Below is what I am trying to get to but I keep getting a compiler error of a missing return statement that looks like this:
PrimeNumber.java:85: missing return statement
}//End Method
I dont understand the error and cant find an explination that I like to make me get it anywhere.
Declare a method to determine whether an integer is a prime number
Use the following method declarations: public static Boolean isPrime (int num)
An integer greater than 1 is a prime number if its only divisor is 1 or itself.
For example, isPrime (11) returns true, and isPrime (9) returns false.
Us the isPrime method to find the first thousand prime numbers and display every ten prime numbers in a row, as follows:
2 3 5 7 11 13 17 19 23 29
31 37 41 43 47 53 59 61 67 71
73 79 83 89 97 … …
Important Notes: The input and output must use JOptionPane dialog and display boxes.
import javax.swing.*; import java.util.Scanner; public class PrimeNumber{ public static boolean isPrime(int num){ Scanner input = new Scanner(System.in); int Odd = input.nextInt(); int Count = 0; int Prime = 1; int Num1; String checker= JOptionPane.showInputDialog("Input your Values:"); Integer Number1 = Integer.parseInt(checker); do{ Num1 = (Prime + 2) / 2; boolean isPrime = true; Count++; if(Num1 != 1){ isPrime = false; break;} } while(Count <= 1000); String message2= String.format("All Prime Numbers: %d\n", Odd); JOptionPane.showMessageDialog(null, message2); }//End method }//End Class PrimeNumber