Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compute the position of an object after free falling for 10 seconds [closed]

Tags:

java

I'm given this basic code:

public class GravityCalculator {
    public static void main(String[] args) {
        double gravity = -9.81; //Earth's gravity in m/s^2
        double initialVelocity = 0.0;
        double fallingTime = 10.0;
        double initialPosition = 0.0;
        double finalPosition = 0.0;
        System.out.println("The object's position after " + fallingTime + " seconds is " + finalPosition+ "m");
        // the output is The object's position after 10.0 seconds is 0.0m
    }
}

And I'm told to modify the program to compute the position of an object falling for 10 seconds, using this formula:

x(t) = 0.5 * at^2 + v(t) + x
a = acceleration = -9.81 m/s
t = time (in seconds) = 10
v = initial velocity
x = initial position

I've tried and tried but the answer I get is 4811.805000000001, but apparently the correct answer is -490.5m.

This is my attempt:

public class GravityCalculator2 {
    public static void main(String[] args) {
        double gravity = -9.81;
        double fallingTime = 10;
        double initialVelocity = 0.0;
        double initialPosition = 0.0;
        double x;
        x = (0.5 * ((gravity * fallingTime) * (gravity * fallingTime)) 
            + (initialVelocity * fallingTime) + (initialPosition));
        System.out.println(x);
    }
}

What did I do wrong?

like image 754
SethZiotic Avatar asked Jul 29 '15 16:07

SethZiotic


People also ask

How far will a free-falling object fall in 10 seconds?

Using the figure of 56 m/s for the terminal velocity of a human, one finds that after 10 seconds he will have fallen 348 metres and attained 94% of terminal velocity, and after 12 seconds he will have fallen 455 metres and will have attained 97% of terminal velocity.

What is the formula for falling objects?

vf = g * t where g is the acceleration of gravity. The value for g on Earth is 9.8 m/s/s. The above equation can be used to calculate the velocity of the object after any given amount of time when dropped from rest.

What is the velocity of an object in free fall after 3 seconds?

If an object is dropped from rest then . . . after 1 second its velocity is -9.8 m/s. after 2 seconds its velocity is -19.6 m/s. after 3 seconds its velocity is -29.4 m/s.


1 Answers

You're code is evaluating this equation:

x(t) = 0.5 * (at)2 + v(t) + x

when it should be evaluating:

x(t) = 0.5 * a(t2) + v(t) + x

The normal understanding of math notation is that exponentiation binds tighter than multiplication.

like image 54
Ted Hopp Avatar answered Nov 13 '22 01:11

Ted Hopp