Question: In Java: You have been asked to write a program that will simulate a bouncy ball in a variety of environments. You will compute the

In Java:

You have been asked to write a program that will simulate a bouncy ball in a variety of environments. You will compute the balls height in feet at each second as time passes on a simulated clock. At time zero, the ball begins at height 0 with a velocity provided by the user in an environment chosen by the user. The environment affects both the velocity decay and the bounciness factor of our ball. After each second, change the height by adding the current velocity, then subtract an amount from velocity based on the table below (see: velocity decay). If the new height is less than zero, multiply both the height and the velocity by the modifier noted in the table below (see: bounciness factor) and print Bounce! as well as the time and height.

In Java: You have been asked to write a program that will

Error Checking You should print error messages if the user enters a gravity choice other than 0, 1, 2 or 3. You should also not allow the user to enter a negative velocity.

EDIT: CLARITY ON VELOCITY:

Within Planet class:

Method Summary
double bounciness() Accessor for planet's bounciness factor
String name() Accessor for the planet's name
double velocityDecay() Accessor for the planet's velocity decay value

velocityDecay

public double velocityDecay()

Returns: the planet's velocity decay.

Example Program Run: The actual numbers in this example may, or may not, be correct!

***Gravity Menu ***

1.) Earth

2.) Discworld

3.) Krypton

0.) Quit

********************

Enter your option: 1

Initial velocity: 100

Time: 1 Height: 100.0

Time: 2 Height: 168.0

Time: 3 Height: 204.0

Time: 4 Height: 208.0

Time: 5 Height: 180.0

Time: 6 Height: 120.0

Time: 7 Height: 28.0

BOUNCE!

Time: 8 Height: 48.0

Time: 9 Height: 126.0

Time: 10 Height: 172.0

//and so on...

***Gravity Menu ***

1.) Earth

2.) Discworld

3.) Krypton

0.) Quit

********************

Enter your option: 2

Initial velocity: 100

Time: 1 Height: 100.0

Time: 2 Height: 194.0

Time: 3 Height: 282.0

Time: 4 Height: 364.0

Time: 5 Height: 440.0

Time: 6 Height: 510.0

Time: 7 Height: 574.0

Time: 8 Height: 632.0

Time: 9 Height: 684.0

Time: 10 Height: 730.0

//and so on...

***Gravity Menu ***

1.) Earth

2.) Discworld

3.) Krypton

0.) Quit

********************

Enter your option: 0

Goodbye!

COSC130 Bouncy Ball Project Submit your solution through Blackboard Program Specification You have been asked to write a program that will simulate a bouncy ball in a variety of environments. You will compute the ball's height in feet at each second as time passes on a simulated clock. At time zero, the ball begins at height 0 with a velocity provided by the user in an environment chosen by the user. The environment affects both the velocity decay and the bounciness factor of our ball. After each second, change the height by adding the current velocity, then subtract an amount from velocity based on the table below (see: velocity decay). If the new height is less than zero, multiply both the height and the velocity by the modifier noted in the table below (see: bounciness factor) and print Bounce!" as well as the time and height Velocity Decay Bounciness Factor -0.5 Planet Earth Discworld Krypton 74 -0.22 Program Design The UML design is provided along with the javadoc of the model solution. It is suggested that you start by having a main method that loops bouncing a ball for a given planet first. After ensuring that this part of your program works correctly, then you should develop the elements of the user interface. Planet Application name: String velocity_decay: double bounciness : double mainfargs : StringM : void > Planet planet_name : String,decay_value: double, bounciness_value: double) namel): String velocity Decay(): double bounciness) : double Bouncy Ball Game input : Scanner earth: Planet discworld: Planet krypton : Planet > Bouncy BallGame) printMenu(): void getChoice(): int getVelocity) : double createBall(planet : int initial_velocity : double): Ball play(): void height : double velocity: double bounces : int planet : Planet bounced : boolean > Ball place: Planet, velocity_value: double) nextSecond(): void height(): double bounced(): boolean is Done(): boolean

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!