Menu Close

Finding runway length needed for aeroplane in Java …FTC

Given take-off speed v and an airplane acceleration a, you can compute the minimum runway length needed for an airplane to take off using the following formula:
length = v^2 / 2a

Input:
Speed v: 60
Acceleration a: 23

Output:
Runway length = 78.26
import java.io.*;
import java.util.*;
public class temp{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a,v;
    System.out.print("Take-off Speed V:  ");
    v = sc.nextInt();
    System.out.print("Airplane acceleration a:  ");
    a = sc.nextInt();

    double length = Math.pow(v,2)/(2*a);

    System.out.println("\nRunway length = "+String.format("%.2f",length));
  }
}

INPUT_1:
Take-off Speed V:  70
Airplane acceleration a:  45

OUTPUT:
Runway length =  54.44


INPUT_2:
Take-off Speed V:  60
Airplane acceleration a:  23

OUTPUT:
Runway length =  78.26


INPUT_3:
Take-off Speed V:  80
Airplane acceleration a:  50

OUTPUT:
Runway length =  64.00


INPUT_4:
Take-off Speed V:  100
Airplane acceleration a:  10

OUTPUT:
Runway length =  500.00


ILLUSTRATION

Executed using javac in linux terminal