Microsoft Visual C# 2015 The Saffir-Simpson Hurricane Scale classifies hurricane
ID: 3788532 • Letter: M
Question
Microsoft Visual C# 2015
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 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.
Design a GUI Form. Must use a nested IF! Create 3 output labels: Category Level, Minimum Wind, and Maximum Wind - display all 3 values.
Explanation / Answer
program plan:
progarm code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Hurricaneapplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (tbws.Text == "")// checks that field can not be empty
{
MessageBox.Show("Field CanNot BE Empty"); // show the meesage if condition is true
}
else
{
panel2.Visible = true;// make panel visible on button click
int i = int.Parse(tbws.Text);// convert string into integer value
if (i <= 74)// first if statement
{
tbcat.Text = "It is not a hurricanes";
tbmins.Text = ("74");
tbmaxs.Text = ("157");
}// end of if
else // else of nested if
{
if (i >= 74 || i <= 95)
{
tbmins.Text = ("74");
tbmaxs.Text = ("96");
tbcat.Text = ("74-96 mph Dangerous Winds");
}// end of third if
if (i >= 96 || i <= 110)
{
tbmins.Text = ("96");
tbmaxs.Text = ("110");
tbcat.Text = ("96-110 mph Very Dangerous Winds");
}// end of fourth if
if (i >= 111 || i <= 130)
{
tbmins.Text = ("111");
tbmaxs.Text = ("130");
tbcat.Text = ("111-129 mph Extremely Dangerous Winds");
}// end of fifth if
if (i >= 130 || i <= 156)
{
tbmins.Text = ("130");
tbmaxs.Text = ("156");
tbcat.Text = ("130-156 mph Extremely Dangerous Winds");
}// end of sixth if
if (i >= 157)
{
tbmins.Text = ("157");
tbmaxs.Text = tbws.Text;
tbcat.Text = ("157" + tbws.Text + "mph Extremely Dangerous Winds");
}// end of seventh if
}// end of nested else
}// end of first else
}// end of method
}// end of class
}// end of namespace