Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Method Edit Hailstone 1 . java ( including updating comments appropriately ) to ask the user for a positive integer and then compute and output

Method
Edit Hailstone1.java (including updating comments appropriately) to ask the user for a positive integer and then compute and output the corresponding Hailstone series. The generation and output of the series should be done in a static method declared as follows (copy the method header, including the documentation comment, from the browser and paste it into Eclipse, replacing only the myMethod method provided in the skeleton program):
1*****
Generates and outputs the Hailstone series starting with the given integ lon
@param n
aparam out
the starting integer
the output stream
/
private static void generateSeries(int n, SimpleWriter out){dots}
Copy Hailstone1. java to create Hailstone2. java (right-click on Hailstone1. java to get the contextual pop-up menu and choose Copy, then right-click on (default package) and choose Paste, providing the new name Hailstone2). Change generateseries (including its Javadoc comments) so that it also computes and outputs the length of the series.
Copy Hailstone2. java to create Hailstone3. java. Change generateSeries (including its Javadoc comments) so that it also computes and outputs the maximum value of the series.
opy ilstone3. java to create Hailstone4.java. Change it so that it repeatedly asks the user whether they wish to calculate another series. If the response is "y", then the program should proceed; if it is anything else, then the program should quit.
Additional Activities
Copy Hailstone4. java to create Hailstone5. java. Change it so that it checks that the input provided by the user is a positive integer. You should implement a new static method declared as follows:
1****
Repeatedly asks the user for a positive integer until the user enters
one. Returns the positive integer.
aparam in
the input stream
eparam out
the output stream
ereturn a positive integer entered by the user
*/
private static int getPositiveInteger(SimpleReader in, SimpleWriter out){.
Note that you cannot assume the user will provide a number; the user can type pretty much anything. So your method should read the input as a String (use simpleReader's nextLine().), then convert the string to an integer (use Integer.parseInt().), and finally check that the integer is positive.
image text in transcribed

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 Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

Explain LIBOR and discuss its influence on the commercial world.

Answered: 1 week ago

Question

Solve Prob. 27.4 with the finite-difference approach using x = 2.

Answered: 1 week ago