Write a program in NetBeans IDE 8.2 for NASA to determine if the weather conditions are favorable for the launch of a new rocket. The program should:
- Ask the user for the sustained wind speed.
- Ask the user for the current daily temperature.
- If the wind speed is above 30 mph or the daily temperature is below 41°F, output that the launch must be aborted.
- Otherwise, output that the rocket is go for launch.
Save the program as RocketLaunch.java
.
Example Runs:
Scenario 1:
Enter sustained wind speed (mph): 15 Enter current daily temperature (°F): 75 Weather conditions are good. The rocket is go for launch.
Scenario 2:
Enter sustained wind speed (mph): 45 Enter current daily temperature (°F): 70 Weather conditions are poor. Abort rocket launch!
Scenario 3:
Enter sustained wind speed (mph): 15 Enter current daily temperature (°F): 35 Weather conditions are poor. Abort rocket launch!
Scenario 4:
Enter sustained wind speed (mph): 105 Enter current daily temperature (°F): -10 Weather conditions are poor. Abort rocket launch!
import java.util.Scanner; public class RocketLaunch { public static void main(String[] args) { // Create a Scanner object to read input from the user Scanner scanner = new Scanner(System.in); // Get the sustained wind speed from the user System.out.print("Enter sustained wind speed (mph): "); double windSpeed = scanner.nextDouble(); // Get the current daily temperature from the user System.out.print("Enter current daily temperature (°F): "); double temperature = scanner.nextDouble(); // Determine if the launch conditions are safe if (windSpeed > 30 || temperature < 41) { // Abort launch if conditions are poor System.out.println("Weather conditions are poor. Abort rocket launch!"); } else { // Proceed with launch if conditions are good System.out.println("Weather conditions are good. The rocket is go for launch."); } // Close the Scanner object scanner.close(); } }