The National Weather Service would like a report about storm activity in the Atl
ID: 3766767 • Letter: T
Question
The National Weather Service would like a report about storm activity in the Atlantic in 2015. Write a Visual C++ program to display the information about the storms described below. Create a project using your last name, first initial and pgm7 for the project folder and .cpp file names (e.g., StormC_pgm7 and StormC_pgm7.cpp).
Input: The storm data is stored in a file called pgm7.txt on Canvas. Each set of two lines in the file contains a storm name and its wind velocity (in miles per hour). Copy this file to your project folder.
[pgm7.txt contents]: Ana 60 Bill 60 Claudette 50 Danny 115 Erika 50 Fred 85 Grace 50 Henri 40 Nine 35 Ida 50 Joaquin 155 Kate 75
Program Design: Your program should define two arrays to hold the data read from the pgm7.txt file – one for the storm names and one for the wind velocities. These two parallel arrays must be declared inside the main function and passed as arguments to the functions that need to use them. Your program should handle data for any number of storms up to a maximum of 15.
Your main function should call the functions described below. Choose a meaningful name for each function based on what it does. Each function should begin with comments describing the purpose of the function.
1. Call a function to read in the storm data from the file pgm7.txt and store it in the two arrays,. Put the data for the first storm in element 0 in each array, the data for the second storm in element 1 of each array, etc.
NOTE: This is the only function that accesses the pgm7.txt data file so declare the file variable, open the file, test the success of opening the file, read in the data and close the file inside this function. All further processing of the data must be done with the data stored in the arrays.
2. Write a function to print the storm data stored in the arrays (see sample below). Include a title for the report, a line underneath the title with your name and a line with column headings. For each storm, print the storm name, wind velocity and the storm category (see table below).
Atlantic Storm Activity for 2015
Your name
Name Wind Velocity Storm Category
----------------------------------------------------------
Ana 60 Tropical Storm
Bill 60 Tropical Storm
etc.
Wind velocity (mph) Storm category
Less than 39 Tropical Depression
39 – 73 Tropical Storm
74 – 95 Hurricane 1
96 – 110 Hurricane 2
111 – 129 Hurricane 3
130 – 156 Hurricane 4
Greater than 156 Hurricane 5
3. Write a function to find the average wind velocity for all storms and return it to the main function to display. For example: Average Wind velocity (knots) = xx.x
4. Call a function to find the storm with the highest wind velocity. The main function should display the name and wind velocity of this storm with appropriate descriptive labels. For example:
Storm xxxxxxxxx had the highest wind velocity of xxx miles per hour.
5. Call a function to sort the arrays in descending (highest to lowest) order by the wind velocity. Be sure that when you switch two elements in the wind velocity array, you also switch the same pair of elements in the storm names array.
6. Call the function from step 2 after the sort to display the list again.
Be sure to include header comments, inline comments and function comments.
Bonus! 2 pt. Call a function to search for a storm by name. Your main function should prompt the user to enter a storm name, pass the name to the search function and print out the information about that storm passed back by the function. For example, if the user enters the storm name Danny, the function should return the position 3. Your main function should display a message like this:
Storm Danny had a wind velocity of 115 miles per hour.
If the user enters a name that is not found in the array (e.g., George), the function should return the value -1. Your main function should display a message like this: No Atlantic storm named George found.
Explanation / Answer
#include<iostream.h>
#include<fstream.h>
using namespace std;
int main()
{
int i=0;
std:: string names[15];
int vel[15];
std:: category[15];
int vel;
string name;
cout<<"Reading dat from file";
ifstream myFile("pgm7.txt");
ReadFile(myFile);
DisplayStorm(name[], vel[]);
cout<<"Average wind velocity %d"<<AverageWind(vel[]);
cout<<"The sorted data";
sort_storm(name[], vel[]);
cout<<"The storm with hioghest wind %d"<< danger_storm(vel[]);
cout<<"enter the storm name";
cin>>storm;
Search(name[], storm, vel[]);
return 0;
}
Note: I'LL provide the other functions in comment..plzzz check out comment.. bcoz of some technical problem I couldnt post it in 120 minutes...
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.