Physics acceleration

The problem

Average acceleration is defined as the change of velocity divided by the time taken to make the change, as shown in the following formula: a = v1 -v / t. Write a program that prompts the user to enter the starting velocity v0 in meters/second, the ending velocity v1 in meters/second, and the time span t in seconds, and displays the average acceleration. Here is a sample run:

Enter v0, v1, and t: 5.5 50.9 4.5
The average acceleration is 10.0889

Breaking it down

public static void main(String[] Strings) {

    Scanner input = new Scanner(;

    System.out.print("Enter v0, v1, and t: ");
    double v0 = input.nextDouble();
    double v1 = input.nextDouble();
    double t = input.nextDouble();


    double acceleration = calculateAcceleration(v0, v1, t);
    System.out.print("The average acceleration is " + acceleration);


private static double calculateAcceleration(double v0, double v1, double t) {
    double acceleration = (v1 - v0) / t;
    return acceleration;


Enter v0, v1, and t: 13 44.5 3.2
The average acceleration is 9.84375