Created
May 4, 2016 01:52
-
-
Save gilrg18/4c038c70ff4271627a84451aa51864bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GravityCalculator { | |
double gravity; | |
double initialVelocity; | |
double fallingTime= 10.0; | |
double initialPosition; | |
public GravityCalculator(double a, double t, double vi, double xi){ //Default Constructor | |
this.gravity=a; | |
this.fallingTime=t; | |
this.initialVelocity=vi; | |
this.initialPosition=xi; | |
} | |
public double finalPosition(){ //Method | |
return 0.5 * (this.gravity)*((this.fallingTime)*(this.fallingTime)) + (this.initialVelocity)*(this.fallingTime) + (this.initialPosition); | |
} | |
public static void main(String[] arguments) { | |
GravityCalculator x = new GravityCalculator(-9.81,10.0,0.0,0.0); //(arguments) | |
System.out.println("Final Position:"+ x.finalPosition()); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment