Design a function named "fallingDistance" that accepts an objects falling time, in seconds, as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Design a program that calls the function in a loop that passes the values 1 through 10 as arguments and displays the return value.
This is what I have, it returns 10 values but it does not take into account the input
public static void main(String[] args) {
double fallTime;
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter the time, in seconds, for how long the object has fallen:");
fallTime = keyboard.nextDouble();
for(int i = 1; i<11; i++)
{
DecimalFormat df = new DecimalFormat("#,#,###.00");
//Print
System.out.println("The object has fallen " + df.format(fallingDistance(i)) + " meters");
}
}
//Function
public static double fallingDistance(double fallTime)
{
//Formula is d = 1/2gt^2
double a = 0.5, gravity = 9.8, distance;
distance = (a * gravity) * (Math.pow(fallTime, 2.0));
return distance;
}
}