Election Program

Basic Program:
Assume there is an election with three candidates.  Each candidate will be identified by their first and last initials (as supplied by the user).  For instance, Bill Clinton would be identified as B C.  Abe Lincoln would be A. L. 

Write a program that asks the user to enter the total number of votes tallied.  Assume a state population of up to 10 million possible voters. 

After the total number of votes has been entered, the user enters the initials for a candidate and then the number of votes they received.  Repeat this process for the other two candidates.

After all user input, the program should report the information, similar to below:

Vote Results

B C = 2000

A L = 2000

M O = 4000

Other = 134

Total Votes = 8134

 

(Note:  The user entered 8134 total votes, but the three main candidates only accounted for 8000 votes.  Therefore, there must have been 134 write-ins)

 

Extension #1

Add the percentage of votes each candidate receives.  (Hint:  When you divide an integer by an integer, your answer will be an integer unless you use typecasting or use float variables.  Typecasting is better…look it up!)

 

Extension #2

Try to figure out how to declare a winner.

 

Extension #3

Try to figure out how to type in names instead of initials

 

Extension #4

Verify numbers – a candidate shouldn’t get 11,000 votes if there were only 10,000 total votes.