#include <iostream>
using namespace std;
// prototype for sumToN, notice the ; at the end
int sumToN(int N);
int main()
{
int wind;
cout << "Enter wind speed: ";
cin >> wind;
int category = 0;
if (wind >= 74 && wind <= 95)
category = 1;
if (wind >= 96 && wind <= 110)
category = 2;
if (wind >= 111 && wind <= 130)
category = 3;
if (wind >= 131 && wind <= 155)
category = 4;
if (wind >= 156)
category = 5;
cout << "Category: " << category
<< endl;
// Second option using if-else structure
if (wind >= 156) // could be > 155
category = 5;
else if (wind >= 131)
category = 4;
else if (wind >= 111)
category = 3;
else if (wind >= 96)
category = 2;
else if (wind >= 74)
category = 1;
else
category = 0; // not a hurricane!
cout << "Category: " << category
<< endl;
cout << "Select a menu option: ";
int option;
cin >> option;
switch (option)
{
case 1:
cout <<
"You'd be printing now\n";
break;
case 2:
cout <<
"You'd be saving the file now\n";
break;
case 3:
cout <<
"You'd exit the program now\n";
break;
default:
cout <<
"Error, invalid option\n";
break;
}
// Function call for sumToN, with initial prompts to
set up values
cout << "Now I'll sum the integers from 1 up
to and including N you choose: ";
int n;
cin >> n;
cout << "The sum is: " << sumToN(n)
<< endl;
}
// Function definition for sumToN
int sumToN(int n)
{
int sum=0;
for (int i=1; i<=n; ++i)
sum += i;
return sum;
}