Tuesday, September 27, 2016

// // Leave a Comment

Physics: Finding Runway Length

The program below is the answer to Liang's Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.12.
Liang's Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.12


/**
 *
 * @Author: Aghatise Osazuwa
 * Website: www.cscprogrammingtutorials.com
 *
 * Exercise 2.12 - Physics: Finding Runway Length
 *
 */ 

import java.util.Scanner;

public class RunwayLength {

    public static void main(String[] args) {
        
        //Display Program Information
        System.out.println("This Program Calculates The Minimum Runway Length "
                + "Needed For An Airplane To Take Off.\n");

        //create Scanner 
        Scanner input = new Scanner(System.in);

        //prompt user to enter details
        System.out.println("Enter speed (in meters per second) and "
                + "acceleration (in meters/second squared):");
        double speed = input.nextDouble();
        double acceleration = input.nextDouble();

        //calculate length 
        double length = ((speed * speed) / (2 * acceleration));
        
        //format length to 4 decimal places
        length = (int)(length * 10000) / 10000.0;

        //display the result
        System.out.println("The minimum runway length for this airplane is "
                + length + "\n");
    }
}

Click here to see other solutions to Introduction to Java Programming.

0 comments:

Post a Comment


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately.

Thanks.