Question: Using the Python language: Write a main program and any necessary functions required to implement a scrutineer's voting machine. The scrutineer is the one that

Using the Python language: Write a main program and any necessary functions required to implement a scrutineer's voting machine. The scrutineer is the one that counts the votes and figures out who won the election. You are writing the program for just the scrutineer to use. Design the program so that the program determines the vote counts for each candidate and find out who won the election. Begin the program by asking how many candidates are running in the election. Then, ask for the last names belonging to each candidate. Next, begin entering the votes. The scrutineer will open the ballot box and will take out each ballot one by one. The scrutineer will enter the index number of the person who was voted for on the ballot.
Issues to Consider:
A)The program will only work for 2 or more candidates B)There could be ties. Deal with the case where more than 1 candidate is tied for the win.
C)Guard against invalid vote entries, (i.e.indices which are out of range)
D)Keep track and report on the number of valid votes cast.
E)Keep track and report on the number of spoiled ballots. A spoiled ballot is not a valid vote cast.
F)Conclude the program by announcing who won the election and how many votes the winner had.
G)Assume the scrutineer will enter a valid integer data type when requested by the program.
SAMPLE SESSION 1
How many candidates are running (e.g.3)>1
Thank you -good bye. You need more than 1 candidate to continue.
SAMPLE SESSION 2 How many candidates are running (e.g.3)>3
Enter lastname of candidate #1>Trump
Enter lastname of candidate #2>Biden
Enter lastname of candidate #3>Salamanca
List of Candidates
-1 for a spoiled ballot
0 Trump
1Biden
2 Salamanca
999 to quit
Enter a vote using the index number beside each candidate.
Enter a vote (e.g.0 or 999 to quit)>-1
Enter a vote (e.g.0 or 999 to quit)>3
Error: 3 is an invalid vote
Enter a vote (e.g.0 or 999 to quit)>0
Enter a vote(e.g.0 or 999 to quit)>1
Enter a vote(e.g.0 or 999 to quit)>1
Enter a vote(e.g.0 or 999 to quit)>1
Enter a vote(e.g.0 or 999 to quit)>2
Enter a vote(e.g.0 or 999to quit)>999
Election Results-----------------
Trump 1
Biden 3
Salamanca 1
numbers spoiled: 1 Total valid votes cast: 5
The winner is Biden with 3 votes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!