
Develop the program calculateHeight, which computes the height that a rocket reaches in a given amount of time. If the rocket accelerates at a constant rate g, it reaches a speed of g �· t in t time units and a height of 1/2 * v * t where v is the speed at t.

Hi Friend,
Try the following code:
import java.util.*;
import java.text.*;
class CalculateHeight{
public static void main(String[] args){
DecimalFormat df = new DecimalFormat("##.00");
Scanner input=new Scanner(System.in);
System.out.print("Enter constant rate:");
double g=input.nextDouble();
System.out.print("Enter time:");
double t=input.nextDouble();
double speed=g*t;
double h=speed*t;
double height=h/2;
System.out.println("Rocket reaches at the height of: "+df.format(height));
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.