Question
(Java) If-Else (Saffir-Simpson Hurricane Wind Scale Calculator) The Saffir-Simpson Hurricane Wind Scale is a 1 to 5 rating based on a hurricane's sustained wind speed.
(Java) If-Else (Saffir-Simpson Hurricane Wind Scale Calculator)
The Saffir-Simpson Hurricane Wind Scale is a 1 to 5 rating based on a hurricane's sustained wind speed. This scale estimates potential property damage. Hurricanes reaching Category 3 and higher are considered major hurricanes because of their potential for significant loss of life and damage. Category 1 and 2 storms are still dangerous, however, and require preventative measures. The Saffir-Simpson Scale is defined in the following table: Category | Sustained Winds 1 | 74 windSpeed < 96 mph 2 | 96 windSpeed < 111 mph 3 | 111 windSpeed < 130 mph 4 | 130 windSpeed < 157 mph 5 | windSpeed of 157 mph or higher Your program must calculate the scale of the hurricane described by the user's input, which will be given in km/h and not in mph. Thus, you must transform it to mph before assigning the scale (1 km/h corresponds to .62 mph). Finally, your code needs to print in console the following message: " __ mph is classified as __ in the Saffir-Simpson Hurricane Wind Scale" (completing the missing blank with the respective speed in mph and the scale), and the message "__ mph does not qualify as hurricane" in case the sustained wind speed specified by the user is lower than 74 mph (completing the missing blank with the respective speed in mph). Examples of input/output: E.g. Enter hurricane's sustained wind speed (in km/hr): 30 | Output in console: "18.6 mph does not qualify as hurricane" E.g. Enter hurricane's sustained wind speed (in km/hr): 199 | Output in console: "123.38 mph is classified as 3 in the Saffir-Simpson Hurricane Wind Scale"
1
import java.util.Scanner;
2
3
public class Lab3 {
4
public static void main(String[] args){
5
// Create a scanner to read from keyboard
6
Scanner kbd = new Scanner (System.in);
7
8
System.out.print("Enter hurricane's sustained wind speed (in km/h): ");
9
10
int windSpeedInKmh = kbd.nextInt();
11
12
//Definition of the variable that will store the scale of the hurricane
13
int scale;
14
15
//YOU MUST NOT WRITE ANY CODE ABOVE THIS LINE
16
17
// TODO: add your code here
18
19
20
}
21
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started