Question: // This code is written in C#...instead of using else if statements i need it to use arrays, the code works just fine and is

//This code is written in C#...instead of using "else if" statements i need it to use arrays, the code works just fine and is a console application.

using System;

namespace VariableDefinition

{

class Program

{

static void Main()

{

int i;

int max = int.MinValue;

bool going = true;

while (going)

{

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

string s = Console.ReadLine();

if (s == "q" || s == "Q")

break;

i = Convert.ToInt32(s);

if (max < i)

max = i;

if (i <= 0)

{

Console.WriteLine("Invalid input!");

}

else

{

if (i < 74)

{

Console.WriteLine("tropical storm not a typhoon");

}

else if ((i >= 74) && (i <= 95))

{

Console.WriteLine("Category 1 with 70 mph");

}

else if ((i >= 96) && (i <= 110))

{

Console.WriteLine("Category 2 with 110 mph");

}

else if ((i >= 111) && (i <= 130))

{

Console.WriteLine("Category 3 with 175 mph");

}

else if ((i >= 131) && (i <= 155))

{

Console.WriteLine("Category 4 with 131 mph");

}

else if (i >= 156)

{

Console.WriteLine("Category 5 with 170 mph");

}

Console.WriteLine("Highest wind speed was " + max);

}

}

}

}

}

//This code is written in C#...instead of using "else if" statements i need it to use arrays, the code works just fine and is a console application.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!