Question: C + + ONLY PLEASE The data in file Income.csv represents the average annual income by state for the years 2 0 1 6 -

C++ ONLY PLEASE
The data in file Income.csv represents the average annual income by state for the years
2016-2018. In addition to the average salaries, the data contains a state name and a
ranking based on the 2018 salaries.
The first program (PGM12-1.cpp) 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[80];
double pop2018;
double pop2017;
double pop2016;
int rank;
};
record #1 Alabama 49861481234625746
record #2 Alaska 7434673181764409
record #3 Arizona 59246565815355828
record #4 Arkansas 47062458694433449
record #5 California 7527771805677397
Program 12-1 has completed
Press any key to continue ...
A second program (PGM12-2.cpp) 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 201820172016
--------------------------------------
146 Alabama 498614812346257
29 Alaska 743467318176440
328 Arizona 592465658153558
449 Arkansas 470624586944334
57 California 752777180567739
-------------------------------------
Average USA 611585911257666
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 1-51. Zero (0) 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 (0 to exit): -1
Invalid state number, please re-enter
Enter a state number to display (0 to exit): 53
Invalid state number, please re-enter
Enter a state number to display (0 to exit): 3
28 Arizona 592465658153558
Enter a state number to display (0 to exit): 1
46 Alabama 498614812346257
Enter a state number to display (0 to exit): 0
Program PGM12-2 has completed
Income.csv
\table[[Alabama,49861,48123,46257,46],[Alaska,74346,73181,76440,9],[Arizona,59246,56581,53558,28],[Arkansas,47062,45869,44334,49],[California,75277,71805,67739,7],[Colorado,71953,69117,65685,12],[Connecticu,76348,74168,73433,6],[Delaware,64805,62852,61757,17],[Florida,55462,52594,50860,38],[Georgia,58756,56183,53559,29],[Hawaii,80212,77765,74511,4],[Idaho,55583,52225,51807,37],[Illinois,65030,62992,60960,16],[Indiana,55746,54181,52314,35],[lowa,59995,58570,56247,26],[Kansas,58218,56422,54422,31],[Kentucky,50247,48375,46659,45],[Louisiana,47905,46145,45146,47],[Maine,55602,55277,53079,36],[Maryland,83242,80776,78945,2],[Massachus,79835,77385,75297,5],[Michigan,56697,54909,52491,32],[Minnesota,70315,68388,65599,14],[Mississippi,44717,43529,41754,50],[Missouri,54478,53578,51746,40],[Montana,55328,53386,50027,39],[Nebraska,59566,59970,56927,27],[Nevada,58646,58003,55180,30],[New Hamp,74991,73381,70936,8],[New Jerse),81740,80088,76126,3],[New Mexic,47169,46744,46746,48],[New York,67844,64894,62909,15],[North Caro,53855,52752,50584,41],[North Dako,63837,61843,60656,19],[Ohio,56111,54021,52344,34],[Oklahoma,51924,50051,49176,44],[Oregon,63426,60212,57532,20],[Pennsylvar,60905,59105,56907,22],[Rhode Islal,64340,63870,60596,18],[South Carc,52306,50570,49501,43],[South Dakc,56274,56521,54467,33],[Tennessee,52375,51340,48547,42],[Texas,60629,592

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!