Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java program that meets the following requirements: Declare a method to

ID: 3618599 • Letter: W

Question

Write a Java program that meets the following requirements:

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 61 73 79 83 89 97 … …

import javax.swing.JOptionPane;


public class CheckPrimeFinder
{

   /**Main Method*/
   public static void main(String[] args)

   {
       
      String numStr;
    
    
      do

      {
  
//Enter a number between 1 and 1000
         numStr = JOptionPane.showInputDialog(null, "Enter a number between 1 and 1000");

         if(numStr==null || numStr.trim().equals(""))

         {

           continue;

         }

         if("0".equals(numStr))

         {

           break;


       }
      
  
        int input = Integer.parseInt(numStr);

     
  
         if(input>0)

         {
        
  
      if(isPrime(input))

         {

           JOptionPane.showMessageDialog(null, input + " is prime");
     
         }

           else
       
        
         {

           JOptionPane.showMessageDialog(null, input + " is not a prime");
    
  
      }
       
     
         }

         else

         }     
         {

            JOptionPane.showMessageDialog(null, "Enter number >0");

   
         }
      

    }
while(true);


// end do .... while

} // end main()


   public static boolean isPrime ( int num )
   {
     boolean prime = true;
     int limit = (int) Math.sqrt ( num );

     for ( int i = 2; i <= limit; i++ )
     {
     if ( num % i == 0 )
     {  


  
   public static boolean isPrime(int num)
  
   {

     //throw new UnsupportedOperationException("Not yet implemented");
  
     boolean b = true;

              
     int i;
              
     int j;
              
     int n;
             
       
     for(i=1;i<num;i++)
            

     //int j;
              
     for(j=2;j<i;j++)
              
     {
                       
        n = num %j;
                       
                       
            
        if(n==0)
                     
        {
                     
           b = false;
           
        }

             
      }
                       
  
   }

        
        &

Declare a method to determine whether an integer is a prime number

Use the following method declarations: public static Boolean isPrime (int num)

Explanation / Answer

please rate - thanks import javax.swing.JOptionPane; public class CheckPrimeFinder {/**Main Method*/ public static void main(String[] args)      {String numStr="The prime numbers
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote