/*	Vote Analysis program. Names and votes for two candidates are
 entered and the percentages and votes are displayed in a table      */

#include <iostream.h>
#include <lvp\string.h>

int main()
{
	cout << "--Vote Analysis Program--" << endl << endl;

	String Candidate1, Candidate2;
	cout << "Enter name of first candidate: ";
	cin >> Candidate1;
	cout << "Enter name of second candidate: ";
	cin >> Candidate2;

	long Votes1, Votes2;
	cout << "Enter votes for " << Candidate1 << ": ";
	cin >> Votes1;
	cout << "Enter 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 = 10;    // Width of columns in table
	cout.setf(ios::fixed);
	cout.precision(2);

	// Output column headings
	cout.setf(ios::left);
	cout.width(ColWidth); cout << "Candidate";
	cout.setf(ios::right);
	cout.width(ColWidth); cout << "Votes";
	cout.width(ColWidth); cout << "Percent" << endl;

	// Output election results 
	cout.setf(ios::left);
	cout.width(ColWidth); cout << Candidate1;
	cout.setf(ios::right);
	cout.width(ColWidth); cout << Votes1;
	cout.width(ColWidth); cout << Percent1 << endl;

	cout.setf(ios::left);
	cout.width(ColWidth); cout << Candidate2;
	cout.setf(ios::right);
	cout.width(ColWidth); cout << Votes2;
	cout.width(ColWidth); cout << Percent2 << endl;

	cout.width(ColWidth); cout << "TOTAL: ";
	cout.width(ColWidth); cout << VotesTotal << endl;

	return(0);
}





