Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need Help fixing my code: here is my code import java.util.Scanner; public class One { public static void main(String[] args) { Scanner input = new

Need Help fixing my code:

here is my code

import java.util.Scanner;

public class One

{

public static void main(String[] args)

{

Scanner input = new Scanner(System.in);

System.out.print("Enter the initial velocity of ball : ");

double vel = input.nextDouble();

int time = 0;

double height = 0;

int bounce = 0;

while(bounce < 5)

{

System.out.println("Time: " + time + "Height: " + height);

time++;

height = height +vel;

vel = vel - 32;;

if(height < 0);

{

height *= -0.5;

vel *= -0.5;

System.out.println("Bounce");

bounce++;

}

}

System.out.println("Stop");

}

}

Here is the problem

home / study / engineering / computer science / computer science questions and answers / write a program that simulates a bouncing ball by computing its height in feet at each second ...

Question: Write a program that simulates a bouncing ball by computing its height in feet at each second as ...

(1 bookmark)

Write a program that simulates a bouncing ball by computing its height in feet at each second as time passes on a simulated clock. At time zero, the ball begins at height zero and has an initial velocity supplied by the user. (An initial velocity of at least 100 feet per second is a good choice.) After each second, change the height by adding the current velocity; then then subtract 32 from the velocity. If the new height is less than zero, multiple both the height and the velocity by -.5 to stimulate the bounce. Stop at the fifth bounce. The output should be the following form

Enter the initial velocity of the ball: 100

Time: 0 Height: 0.0

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

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_2

Step: 3

blur-text-image_3

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

Has your organisation defined its purpose, vision and mission?

Answered: 1 week ago