Question: Write a Java program that implements the following state diagram. Turn in a listing of your program, and the results of a test run with

Write a Java program that implements the following state diagram. Turn in a listing of your program, and the results of a test run with n = 97. You will need to know how to do input in Java. Use the following construct and include the given class in your program.
int n = (new IntReader()).readInt();
import java.io.*;
// a class to read in an integer
public class IntReader{
private LineNumberReader d;
public IntReader(){
d = new LineNumberReader(new BufferedReader(new
InputStreamReader(System.in)));
} // end of constructor
public int readInt(){
try{
return(Integer.parseInt(d.readLine()));
}catch(Exception e){}
return(Integer.MAX_VALUE);
} // end of readInt
} // end of class IntReader
 Write a Java program that implements the following state diagram. Turn

readNumber update entry -reado exit otPrime true [n != 01/ i )notPrime = false handleZero checkPrime doDivide exit / notPrime = true [i > notPrime) writeResult [notPrime writeYes entry/ write(prime") InotPri writeNo entry/writenot prime")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!