Using the Design Recipe and NetBeans, construct an algorithm, and then write a J
ID: 3798553 • Letter: U
Question
Using the Design Recipe and NetBeans, construct an algorithm, and then write a Java program based on the algorithm, to solve each of the following problems:(Engineering: finding runway length) Given an airplane's acceleration a and take-off speed v, you can compute the minimum runway length needed for an airplane to take off using the following formula:
Write a program that prompts the user to enter v in meters/second (m/s) and the acceleration a in meters/second squared (m/s2), and displays the minimum runway length.
Sample Run (user input in color):
run:
Enter speed in meters/second: 60
Enter acceleration in meters/second squared: 3.5
The minimum runway length for this airplane is 514.3
BUILD SUCCESSFUL (total time: 10 seconds)
Explanation / Answer
SpeedCalc.java
import java.text.DecimalFormat;
import java.util.Scanner;
public class SpeedCalc {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter speed in meters/second: ");
double speed = scan.nextDouble();
System.out.println("Enter acceleration in meters/second squared: ");
double acceleration = scan.nextDouble();
double minRunwayLen = calculateRunwayLength(speed, acceleration);
DecimalFormat df = new DecimalFormat("0.0");
System.out.println("The minimum runway length for this airplane is "+df.format(minRunwayLen));
}
public static double calculateRunwayLength(double speed, double acceleration){
double minRunwayLen = (speed * speed) / (2 * acceleration);
return minRunwayLen;
}
}
Output:
Enter speed in meters/second:
60
Enter acceleration in meters/second squared:
3.5
The minimum runway length for this airplane is 514.3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.