/* Andras Konya 9/23/01 Chapter 3 Review 15 --- Case Study with Remodified Columns*/ #include #include int main () { cout << "-- Vote Analysis Program --" << endl << endl; apstring Candidate1, Candidate2; cout << "Enter the name of the first candidate: "; cin >> Candidate1; cout << "Enter the name of the second candidate: "; cin >> Candidate2; long Votes1, Votes2; cout << "Enter the votes for " << Candidate1 << ": "; cin >> Votes1; cout << "Enter the votes for " << Candidate2 << ": "; cin >> Votes2; cout << endl; long VotesTotal = Votes1 + Votes2; double Percent1 = 100 * double (Votes1)/VotesTotal; double Percent2 = 100 * double (Votes2)/VotesTotal; const int ColWidth = 6; //Width of columns in table const int ColWidth2 = 10; cout.setf(ios::fixed); cout.precision(2); // Output column headings cout.setf(ios::left); cout.width(ColWidth2); cout << "Candidate"; cout.setf(ios::right); cout.width(ColWidth); cout << "Votes"; cout.width(ColWidth); cout << "Pct" << endl; // Output Election Results cout.setf(ios::left); cout.width(ColWidth2); cout << Candidate1; cout.setf(ios::right); cout.width(ColWidth); cout << Votes1; cout.width(ColWidth); cout << Percent1 << endl; cout.setf(ios::left); cout.width(ColWidth2); cout << Candidate2; cout.setf(ios::right); cout.width(ColWidth); cout << Votes2; cout.width(ColWidth); cout << Percent2 << endl; cout.width(ColWidth2); cout << "TOTAL: "; cout.width(ColWidth); cout << VotesTotal << endl; char dummy; cin >> dummy; return (0); }