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
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
Income.csv
Alabama 49861481234625746 Alaska 7434673181764409 Arizona 59246565815355828 Arkansas 47062458694433449 California 7527771805677397 Colorado 71953691176568512 Connecticu 7634874168734336 Delaware 64805628526175717 Florida 55462525945086038 Georgia 58756561835355929 Hawaii 8021277765745114 Idaho 55583522255180737 Illinois 65030629926096016 Indiana 55746541815231435 lowa 59995585705624726 Kansas 58218564225442231 Kentucky 50247483754665945 Louisiana 47905461454514647 Maine 55602552775307936 Maryland 8324280776789452 Massachus 7983577385752975 Michigan 56697549095249132 Minnesota 70315683886559914 Mississippi 44717435294175450 Missouri 54478535785174640 Montana 55328533865002739 Nebraska 59566599705692727 Nevada 58646580035518030 New Hamp 7499173381709368 New Jerse)8174080088761263 New Mexic 47169467444674648 New York 67844648946290915 North Caro 53855527525058441 North Dako 63837618436065619 Ohio 56111540215234434 Oklahoma 51924500514917644 Oregon 63426602125753220 Pennsylvar 60905591055690722 Rhode Islai 64340638706059618 South Caro 52306505704950143 South Dake 56274565215446733 Tennessee 52375513404854742 Texas 60629592065656525 Utah 71414653586597713 Vermont 60782575135767723 Virginia 72577715356811411 Washingtor 74073709796710610 Washingto 8520382372755061 West Virgir 44097434694338551 Wisconsin

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!