In: Computer Science
In C# The Saffir-Simpson Hurricane Scale classifies hurricanes into five categories numbered 1 through 5. Write an application named Hurricane that outputs a hurricane’s category based on the user’s input of the wind speed. Category 5 hurricanes have sustained winds of at least 157 miles per hour. The minimum sustained wind speeds for categories 4 through 1 are 130, 111, 96, and 74 miles per hour, respectively. Any storm with winds of less than 74 miles per hour is not a hurricane. If a storm falls into one of the hurricane categories, output This is a category # hurricane, with # replaced by the category number. If a storm is not a hurricane, output This is not a hurricane.
Answer)
The code
using System;
//declare the class hurricane
class hurricane
{
//Main started and declared
static void Main()
{
Console.Write("Enter the wind speed in miles per hour:
");
//input taken
string uws = Console.ReadLine();
//input converted from string to integer
Convert.ToInt32() function
int ws = Convert.ToInt32(uws);
//checks the value of ws for the wind categories
if(ws<74)
Console.WriteLine("Not a
hurricane");
if(ws>=74 && ws<96)
Console.WriteLine("This is a
category 1 hurricane");
if(ws>=96 && ws<111)
Console.WriteLine("This is a
category 2 hurricane");
if(ws>=111 && ws<130)
Console.WriteLine("This is a
category 3 hurricane");
if(ws>=130 && ws<157)
Console.WriteLine("This is a
category 4 hurricane");
if(ws>157)
Console.WriteLine("This is a
category 5 hurricane");
}
}
goto command prompt of windows and use a notepad to write the program, then compile it, after that run by the filename only.
Screenshot