CS 115 Program 2 Voting Machine Spring 2001

Due Date: Friday, February 16, 2001

You have been recruited to write a program that will record votes in an election. Hey, it'll be better than punched cards anyway!

The input comes in simply as the initials of the party the person wants to vote for, either D (Democrat), R (Republican) or I (Independent). Your program needs to keep track of how many of each are seen, as well as the number of invalid entries that were entered. When the last person has voted, the precinct worker will enter a q character (for quit). Then your program will report the total number of valid votes, and the percentage and count for each of the three parties.

You should be careful not to divide by zero. Your program should handle both upper and lower case input characters.

Example run:

Voting machine!!
Enter the party letter you wish to vote for (D, R, I, or Q): d
Enter the party letter you wish to vote for (D, R, I, or Q): i
Enter the party letter you wish to vote for (D, R, I, or Q): I
Enter the party letter you wish to vote for (D, R, I, or Q): D
Enter the party letter you wish to vote for (D, R, I, or Q): D
Enter the party letter you wish to vote for (D, R, I, or Q): R
Enter the party letter you wish to vote for (D, R, I, or Q): R
Enter the party letter you wish to vote for (D, R, I, or Q): R
Enter the party letter you wish to vote for (D, R, I, or Q): M
	*** Invalid letter ***
Enter the party letter you wish to vote for (D, R, I, or Q): q

There were 8 valid votes.
There was 1 invalid entry.	
Democrat votes 		3	37.50%
Republican votes	3 	37.50%
Independent votes	2	25.00% 

Testing:
Try runs where there are equal numbers of each party, runs where there are no votes for one party or for two parties, runs where no votes at all are cast.

Please read the documentation standard. As you can see from looking at the grading sheet, we will be looking to see how you meet these standards.

As described in the documentation standard, turn in the following, neatly stapled, in this order: