Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ programming Sorting Election Results There is a file of election results for the 2016 election. Each line contains d or r, for voting Democrat

 c++ programming Sorting Election Results There is a file of election results for the 2016 election. Each line contains d or r, for voting Democrat or Republican, the name of the state, the approximate population, and the number of Representatives. You are to read in the data into an array of struct (ignore line 1), and calculate a ratio of population/electorial_votes. The electorial_votes is the number of representatives+2. Logic: read in the data into an array of struct print the array, as is. sort the array by population (ascending order). print the array (including the ratios). sort the array by ratio (ascending order). print the array (including the ratios). Gotchas: Reading the population is problematic. You have to figure how to skip over the commas. You can have only 1 sort routine. Data for the voting program 
party state population representatives d California 39,144,818 53 d New York 19,795,791 27 d Illinois 12,859,995 18 d New Jersey 8,958,013 12 d Virginia 8,382,993 11 d Washington 7,170,351 10 d Massachusetts 6,794,422 9 d Maryland 6,006,401 8 d Minnesota 5,489,594 8 d Colorado 5,456,574 7 d Oregon 4,028,977 5 d Connecticut 3,590,886 5 d Nevada 2,890,845 4 d New Mexico 2,085,109 3 d Hawaii 1,431,603 2 d New Hampshire 1,330,608 2 d Maine 1,329,328 2 d Rhode Island 1,056,298 2 d Delaware 945,934 1 d Washington DC 658,893 1 d Vermont 626,042 1 r Texas 27,469,114 36 r Florida 20,271,272 27 r Pennsylvania 12,802,503 18 r Ohio 11,613,423 16 r Georgia 10,214,860 14 r North Carolina 10,042,802 13 r Michigan 9,922,576 14 r Arizona 6,828,065 9 r Indiana 6,619,680 9 r Tennessee 6,600,299 9 r Missouri 6,083,672 8 r Wisconsin 5,771,337 8 r South Carolina 4,896,146 7 r Alabama 4,858,979 7 r Louisiana 4,670,724 6 r Kentucky 4,425,092 6 r Oklahoma 3,911,338 5 r Iowa 3,123,899 4 r Utah 2,995,919 4 r Mississippi 2,992,333 4 r Arkansas 2,978,204 4 r Kansas 2,911,641 4 r Nebraska 1,896,190 3 r West Virginia 1,844,128 3 r Idaho 1,654,930 2 r Montana 1,032,949 1 r South Dakota 858,469 1 r North Dakota 756,927 1 r Alaska 738,432 1 r Wyoming 586,107 1 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions