Following is ill-written code intended for judging a number is prime or not. Note that you should point out the problems first and then correct the code . //define variables int number; //Create...


Following is ill-written code intended for judging a number is prime or not.
Note that you should point out the problems first and then correct the code.



     //define variables


     int number;



     //Create scanner


     Scanner myScanner = new Scanner(System.in);



     System.out.println("Please input a positive integer");


     number = myScanner.nextInt();




     for(int counter =1; counter < number;="">


     {


           if (number%counter == 0 ){


                System.out.println(number+" is NOT prime!");


           }


           else{


                System.out.println(number+" is prime!");


                break;


           }


     }//end for



Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here