assignment for my class. here is the assignment:
Project
–
Part 1:
H
-
Engineering (HEg) is a new company that specializes in hurricane research. Recently the National
Oceanic and Atmospheric Administration (NOAA) awarded a contract to HEg
to develop a new software
application that will do various analyses on hurricanes and tropical storms. This SW will be delivered to
the customer in phases as specified in the contract.
Background:
Hurricane season in the Atlantic Basin, which includes the Caribbean and the Gulf of Mexico, officially
runs June 1stto November 30th. Thus, NOAA needs to have a complete application by April. You became
part of the software team responsible to develop the HEg Analyzer v1.0. The first phase of this project is
to create a menu based application for the user to select an option to execute (See Instructions section).
Forv1.0, NOAA only wants the input to be entered for all the storms for two hurricane seasons for the Atlantic Basin. It’ll then print the number of hurricanes by category and the total wind speed for the
season. It’ll also display the month with the highest number of storms with the corresponding windspeed total for that month
Instructions:
1.Display the software name and the following menu
HEg v1.0
--------
0.Exit
1.Submit Hurricane Season Storms Information
2.Print Storm Analysis
Enter Selection:
2. Selection 0: Exits the program with a message:
Thanks for using HEg v1.0
3. Selection 1: User submits the storms data for a particular hurricane year as follows:
HEg v1.0
--------
1. Exit
2. Submit Hurricane Season Storms Information
3. Print Hurricane Season Analysis Enter Selection: 1
Enter the year: 2009
Enter the total number of storms in 2009: 10
Enter the month #, wind speed (mph), and min pressure (mbar) for storm #1: 2, 100, 985 ERROR: Invalid input.
Hurricane season is from June – Nov.
Wind speed for a storm is >38 mph. Try again.
Enter the month #, wind speed (mph), and min pressure (mbar) for storm #1: 6, 30, 985 ERROR: Invalid input.
Hurricane season is from June – Nov.
Wind speed for a storm is >38 mph. Try again.
Enter the month #, wind speed (mph), and min pressure (mbar) for storm #1: 6, 70, 985 Wind speed in knots: 60.82831
Enter the month #, wind speed (mph), and min pressure (mbar) for storm #2:
3.1 After entering the year, the SW asks the user to enter the total number of storms (tropical storms and hurricanes)
3.2 Then, the SW asks the user to enter the month, wind speed (mph), and the minimum pressure (mbar) for each storm. They have to be separated by a comma.
3.3 The software should automatically check the validity of the month entered and each wind speed. The hurricane season is from June through November.
3.4 The software should also check the validity of each wind speed entered based on the chart below:
[ hurricane categories w/ corresponding wind speeds]
For example, if the user enters 2 for the month of February and/or the wrong wind speed, an Error Message should be displayed as follows:
ERROR: Invalid input.
Hurricane season is from June – Nov.
Wind speed for a storm is >38 mph. Try again.
The software should continuously ask the user to enter the correct value until a valid one is entered (Hint: Use a loop).
3.5 If the wind speed input is correct, the SW should print the wind speed in knots
4 Each hurricane season is saved into a 2D-array. The first column has the number for the month, the second column has the wind speed, and the last column the min pressure.
5 It should also keep a running total of all the valid wind speeds in knots
6 After selection 1 is complete, display the menu again.
7 Selection 2: The software will do a simple analysis of the hurricane season
7.1 Categorize each storm to its corresponding storm category: The SW should have another array that contains the total number of storms for each storm category. For example, the 2006 hurricane season has a total of 10 storms, of which: 5 are tropical storms, 3 are category one, and 2 are category three hurricanes. Thus, the category array should look like this:
0 1 2 3 4 5
5 3 0 2 0 0
7.2 It then prints the number tropical storms, the number of hurricanes for each category as follows.
7.3 In Selection 3, the SW also analysis the total number of storms per month and determines what month has the highest number of storms. And it’ll display the month number and the total wind speed for that month. Hint: you may use another array
7.5 Lastly, it should display the total wind speed for 2006, as shown in 7.3
7.6 If the user didn’t enter any information for a particular hurricane season and selects #2, an error should occur (like v.1.0)
ERROR: Hurricane Season data was not entered. Select Option 1.
8 Invalid Selection number: Print an error message if the user enters any other selection number other than 0, 1, or 2.:
ERROR: Menu option not available in HEg v1.0
I cannot seem to figure this thing out. I'm using devc++ to write with. this is my code so far but it's not working for selection #2
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int selection;
/* start screen information and phrases */
while(selection>0){
printf("\n HEG v1.0\n");
printf(" --------\n");
printf("0. Exit\n");
printf("1. Submit Hurricane Season Storms Information\n");
printf("2. Print Storm Analysis\n");
printf("\nEnter Selection: ");
scanf("%d", &selection);
int year;
int r;
int storms;
int month;
int wind;
int stormarray[storms][3];
float knots;
int catarray[6]={0};
/* use switch and case command to execute code for each selection */
switch(selection)
{
case 0:
printf("\nThanks for using HEg v1.0\n\n");
break;
case 1:
printf("Enter the year: \n");
scanf("%d", &year);
printf("Enter the total number of storms in %d: ", year);
scanf("%d", &storms);
for(r=0; r<storms; r++)
{
printf("\nEnter the month #, wind speed (mph), and min pressure (mbar) for storm #%d:\n",r+1);
scanf("%d, %d, %d",&stormarray[r][0], &stormarray[r][1], &stormarray[r][2]);
if(stormarray[r][0] > 11 || stormarray[r][0] < 6)
{
printf("ERROR: Invalid input.\n Hurricane season is from June-Nov.\n Windspeed for a storm is >38mph. Try again.\n");
r--;
}
else if(stormarray[r][1] > 38)
{
/* tropical storm */
if(stormarray[r][1]>38 && stormarray[r][1]<74)
{
catarray[0]++;
knots=((stormarray[r][1])*(.8689762));
printf("Wind speed in knots:%f\n ", knots);
}
/* category 1 */
else if(stormarray[r][1]>73 && stormarray[r][1]<96)
{
catarray[1]++;
knots=((stormarray[r][1])*(.8689762));
printf("Wind speed in knots:%f\n ", knots);
}
/* category 2 */
else if(stormarray[r][1]>95 && stormarray[r][1]<111)
{
catarray[2]++;
knots=((stormarray[r][1])*(.8689762));
printf("Wind speed in knots:%f\n ", knots);
}
/* category 3 */
else if(stormarray[r][1]>110 && stormarray[r][1]<130)
{
catarray[3]++;
knots=((stormarray[r][1])*(.8689762));
printf("Wind speed in knots:%f\n ", knots);
}
/* category 4 */
else if(stormarray[r][1]>129 && stormarray[r][1]<157)
{
catarray[4]++;
knots=((stormarray[r][1])*(.8689762));
printf("Wind speed in knots:%f\n ", knots);
}
/* category 5 */
else
{
catarray[5]++;
knots=((stormarray[r][1])*(.8689762));
printf("Wind speed in knots:%f\n ", knots);
}
}
else{
printf("ERROR: Invalid input.\n Hurricane season is from June-Nov.\n Windspeed for a storm is >38mph. Try again.\n");
r--;
}
}
break;
case 2:
printf(" %d Hurricane Season Aanalysis\n", year);
printf(" ------------------------------\n");
printf("\nTotal number of tropical storms:%d \n",catarray[0]);
printf("Total number of Category 1 Hurricanes:%d \n",catarray[1]);
printf("Total number of Category 2 Hurricanes:%d \n",catarray[2]);
printf("Total number of Category 3 Hurricanes:%d \n",catarray[3]);
printf("Total number of Category 4 Hurricanes:%d\n",catarray[4]);
printf("Total number of Category 5 Hurricanes:%d \n",catarray[5]);
break;
}
}
system("PAUSE");
return 0;
}