THINK FIRST·CODE LATER

← All labs

Take-off: how long must the runway be?

Problem

A plane accelerates steadily from rest until it reaches its take-off speed. Physics gives:

time   ← speed / acceleration
length ← speed × speed / (2 × acceleration)

Runway reads the take-off speed in m/s and the acceleration in m/s², and prints the speed in km/h (× 3600 / 1000), the time on the runway and the minimum runway length, each with one decimal. For the input

60 3.5

the program prints

Take-off speed: 216.0 km/h
Time on the runway: 17.1 s
Minimum runway length: 514.3 m

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

l2-9-data-1.txt

60 3.5
What your program must print for l2-9-data-1.txt
Take-off speed: 216.0 km/h
Time on the runway: 17.1 s
Minimum runway length: 514.3 m

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < l2-9-data-1.txt

Windows PowerShell does not understand <:

Get-Content l2-9-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.