I have this project that I'm working on for my class, but I'm getting stuck with infinite loops and I'm not really sure what's wrong.
I'm supposed to assume that at time 0, the ball is at height 0 and the velocity is input by the user.
After each second the height is changed by adding the current velocity then subtracting 32.
If the height is less than zero, multiply north the height and velocity by -0.5, print "Bounce!" as well as the time and height.
And the loop is supposed to run until the ball comes to rest or bounces 5 times.
Any help would be much appreciated.
The for loop as it is now:
for(float height = velocity; height>=0; time++)
{
if (height<=0)
{
height*=-0.5;
velocity*=-0.5;
System.out.println("Bounce!\nTime: " + time + " Height" + height);
}
else
{
System.out.println("Time: " + time + " Height: " + (height-32));
}
}