Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

8. Managers are not trained to be innovation leaders.

Answered: 1 week ago