Answer to Question #307570 in C# for kun

Question #307570

The Saffir-Simpson Hurricane Scale classifies hurricanes into five categories numbered 1 to 5.


Write a program that outputs a hurricane’s category based on the user’s input of the wind speed.


You may assume that wind speeds will be provided as integer values.


The categories are as follows:



252 km/h or higher-- 5


209 – 251 km/h --4


178 – 208 km/h --3


154 – 177 km/h-- 2


119 – 153 km/h --1



Any storm with winds of less than 119 km/h is not a hurricane


1
Expert's answer
2022-03-07T18:04:13-0500
using System;




namespace HurricaneScale

{

  class Program

  {

    static void Main(string[] args)

    {

      int WindSpeed = -1;

      Console.WriteLine("Enter the wind speed");

      WindSpeed = int.Parse(Console.ReadLine());

      if (WindSpeed < 119)

        Console.WriteLine("Storm with winds of less than 119 km/h is not a hurricane");

      if (WindSpeed >= 119 && WindSpeed <= 153)

        Console.WriteLine("1");

      if (WindSpeed >= 154 && WindSpeed <= 177)

        Console.WriteLine("2");

      if (WindSpeed >= 178 && WindSpeed <= 208)

        Console.WriteLine("3");

      if (WindSpeed >= 209 && WindSpeed <= 251)

        Console.WriteLine("4");

      if (WindSpeed >= 252)

        Console.WriteLine("5");

    }

  }

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Blake Poindexter
15.02.23, 05:30

Oh, this makes more sense. I was trying to think of a way to use a switch-case structure but that seemed more convoluted. I do recall the textbook saying though that there were limitations to using switch structures and that there would be instances were if statements would be more efficient. Thank you for your insight!!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS