Question: Objectives Practice do - while loop, data type validation, and Random class. Problem Write a program that simulates a person trying to climb up a

Objectives
Practice do-while loop, data type validation, and Random class.
Problem
Write a program that simulates a person trying to climb up a mountain. The person starts on the
ground, at height 0. Each iteration, the person climbing up the mountain either moves up a
random number of steps between 1-5. Or the person slips down a random number of steps
between 1 and 5. There is a 50% chance on each iteration that the person either climbs up or
slips down therefore a random number 0 or 1 must be generated to decide if the person will
climb up or slips down. Refer to the sample output.
Requirements
A shell has been provided with some code in it. You need to complete it
Must provide all the method
Must follow the requirements
Your output will not match my output since we are using the random class and numbers
are being generated randomly.
Refer to the rubric regarding the comments, indentation, proper naming, and other
requirements.
Codes submitted from the previous semesters will receive zero
Methods
Public static int input (): this method asks the user for the height of the mountain. As long as the user is
not entering a valid height, your program must ask the user again. Must use a while and a do while loop
in this method. This method must check for three things: integer value and also it must be a positive
integer. And must be less than the MAX_HEIGHT. Refer to the video for the sample code. The mountain
height that user enters must be an integer greater than zero. (data type validation and range validation are
being done). The range of the mountain height is between 1 and a maximum value
public static int climb (): refer to the provided shell
Public static void execute (): refer to the provided shell
public static void main (String [] args): refer to the shell
Public static void description (): displays a description of the program.

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 Programming Questions!