Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

2 What supply is and what affects it.

Answered: 1 week ago