Gravity Calculator

$4.99

Category:

Description

GravityCalculator.java

Create a program that computes the distance an object will fall in Earth’s gravity.

  1. Create a new class called GravityCalculator.

  2. Copy and paste the following initial version:

import java.io.;import java.io.;

public class GravityCalculator {

public static void main(String[] arguments){

double  gravity =-9.81; // Earth’s gravity in m/s^2

double  initialVelocity = 0.0; // starting velocity of the object

double  fallingTime = 10.0; // time in seconds that the object falls

double  initialPosition = 1000.0; // Starting position in meters, the calculation will determine the ending position in meters

double  finalPosition = 0.0;

System.out.println(“The object’s position after ” + fallingTime +” seconds is “+finalPosition + ” m.”);
}

}

  1. Run it

  2. Modify the example program to compute the position of an object after falling for 10 seconds, outputting the position in meters. The formula in Math notation is:

x(t) = 0.5at^2 + vit + xi

gravity calculator

 

Submit your GravityCalculator.java file along with the output you received when running it. The output should be captured as a screen capture or by cutting and pasting the output from the window that the output of your program is displayed in.