Question: C + + using namespace std; PLEASE The data in file Income.csv represents the average annual income by state for the years 2 0 1
C using namespace std;
PLEASE
The data in file Income.csv represents the average annual income by state for the years
In addition to the average salaries, the data contains a state name and a
ranking based on the salaries.
The first program PGMcpp will read the data from the file Income.csv and create
an output binary file called Income.dat. You must create an instance of a struct like the
one listed below to store each record before writing that struct instance to the output file.
Display each record read including the record number in
the file as the output shows
below this is the result of the input file containing only the first five records
struct Record
char state;
double pop;
double pop;
double pop;
int rank;
;
record # Alabama
record # Alaska
record # Arizona
record # Arkansas
record # California
Program has completed
Press any key to continue
A second program PGMcpp will read the binary file Income.dat and create a
report that is written to a text file called Report.txt The Report.txt file should resemble
the format below. Please take the time to align the data as shown.
In this program you must assign a state number which is the position the record is in the
file. You will need to determine and print a total line for the USA that will contain the
average for each year. In this case the average will not have any decimal positions, but
must be calculated with rounding.
The Report.txt file format is this is the result of the input file containing only the first
five records:
Number Rank State
Alabama
Alaska
Arizona
Arkansas
California
Average USA
Include a query of the data by prompting the user to enter a state number. Edit the user
input for numbers outside the range of Zero is the sentinel value that ends the
program. Using random access to the binary file, find the data for the state requested.
The following is a typical script. This data should be displayed on the console, not in the
Report.txt file.
Enter a state number to display to exit:
Invalid state number, please reenter
Enter a state number to display to exit:
Invalid state number, please reenter
Enter a state number to display to exit:
Arizona
Enter a state number to display to exit:
Alabama
Enter a state number to display to exit:
Income.csv
Alabama Alaska Arizona Arkansas California Colorado Connecticu Delaware Florida Georgia Hawaii Idaho Illinois Indiana lowa Kansas Kentucky Louisiana Maine Maryland Massachus Michigan Minnesota Mississippi Missouri Montana Nebraska Nevada New Hamp New Jerse New Mexic New York North Caro North Dako Ohio Oklahoma Oregon Pennsylvar Rhode Islai South Caro South Dake Tennessee Texas Utah Vermont Virginia Washingtor Washingto West Virgir Wisconsin
