<br /> Lincoln 120 300 400<br /> Parks 100 500 250<br /> Shakespeare 0 30 50<br /> Ghandi 250 100 40<br /> Ashe 300 50 175<br /> Rodriguez 87 118 320<br /> Curie 284 0 112<br />
<br /> void displayResults(int list[][COL_SIZE],string nameList[])<br /> {<br /> <br /> // this will be a function to calcualte percentage of all the calculations<br /> double percenttotal = 0;<br /> int num = 0,votenum = 0;<br /> double perc = 0;<br /> string n;<br /> cout << "Results in sorted order" << endl;<br /> cout << "Name Votes % Total " << endl;<br /> cout << "----------- ------ ------" << endl;<br /> for (int c = 0; c < COL_SIZE;c++)<br /> {<br /> cout << nameList[c] << '\t' << '\t';<br /> votenum = 0;<br /> //this will display the names to the left <br /> for (int r = 0; r < ROW_SIZE - 1; r++)<br /> {<br /> //this adds the precinct to the right ROW totals<br /> votenum = votenum + list[r][c];<br /> }<br /> percenttotal = votenum / 100.0;<br /> cout << votenum <<"\t"<< percenttotal <<"%"<< endl;<br /> }<br /> cout << "----------------------------------------------" << endl;<br /> }
<br /> Results in sorted order<br /> Name Votes % of Total<br /> ----------- ----- ----------<br /> Parks 850 23.7%<br /> Lincoln 820 22.9%<br /> Ashe 525 14.6%<br /> Rodriguez 525 14.6%<br /> Curie 396 11.0%<br /> Ghandi 390 10.9%<br /> Shakespeare 80 2.2%<br />
list
nameList
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)