The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.12.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.12 - Physics: Finding Runway Length<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class RunwayLength {<br /><br /> public static void main(String[] args) {<br /> <br /> //Display Program Information<br /> System.out.println("This Program Calculates The Minimum Runway Length "<br /> + "Needed For An Airplane To Take Off.n");<br /><br /> //create Scanner <br /> Scanner input = new Scanner(System.in);<br /><br /> //prompt user to enter details<br /> System.out.println("Enter speed (in meters per second) and "<br /> + "acceleration (in meters/second squared):");<br /> double speed = input.nextDouble();<br /> double acceleration = input.nextDouble();<br /><br /> //calculate length <br /> double length = ((speed * speed) / (2 * acceleration));<br /> <br /> //format length to 4 decimal places<br /> length = (int)(length * 10000) / 10000.0;<br /><br /> //display the result<br /> System.out.println("The minimum runway length for this airplane is "<br /> + length + "n");<br /> }<br />}<br /> |
Click here to see other solutions to Introduction to Java Programming.