Question: Instructions Carefully read through the project objectives and activities an ensure your solution correctly meets the objectives. Note: Submission of any ChatGPT - generated code
Instructions
Carefully read through the project objectives and activities an ensure your solution correctly meets the objectives.
Note: Submission of any ChatGPT generated code or segment of code will result in total score of of the total score for this project
Project Objectives:
Read Votes from File
Create a function to read the votes from the "castedvotes" file and organize them for counting.
Count Votes per Candidate and Write Results to File
Implement a function to count the number of votes cast for each candidate in the read vote data and write the results into the "countedvotes" file.
Check for Simple Majority
Develop a method to determine if any candidate in the firstchoice list receives more than of the votes.
Identify Equal Votes
Implement a function to check if all candidates in the firstchoice list have an equal number of votes.
Ranked Choice Voting Algorithm RCV
Write a function that executes the RCV algorithm using the read vote data:
If a candidate gets more than of the firstchoice votes, declare that candidate as the winner.
If no candidate has a majority, eliminate the candidate with the fewest votes and redistribute their votes to the next available choices.
Continue eliminating candidates until a winner with a majority is determined.
Steps to Implement:
Read Votes from File
Create functions to read the votes from the "castedvotes" file.
Vote Counting and Writing Results to File
Implement functions to tally the votes for each candidate based on the read file data and write the results into the "countedvotes" file.
Majority Determination
Develop a function to check if any candidate has a simple majority in the read vote data.
Elimination and Redistribution
Write a function to eliminate the candidate with the fewest votes and redistribute those votes to the next available choices based on the read vote data.
Loop for RCV Process
Implement a loop to execute the RCV process until a winner is determined using the read vote data.
Note:
Each of the objectives carries maximum score of
Total score for this project
Project submission date is Sunday, th April, @ :pm
Submission format: Python script with py extension
Project defense date: The date and time scheduled for the written examination for this course
Defense Order: To be decided by the course Lecturer
Example Apology; there was an error in the elimination process in the example which has now been corrected
Suppose there are candidates A B C D E and voters who rank them as follows:
voters rank: A B C D E
voters rank: B C A D E
voters rank: C B D A E
voters rank: D E C B A
voters rank: E D C B A
In the first round of counting, the votes are tallied:
A receives votes
B receives votes
C receives votes
D receives votes
E receives votes
Since no candidate has a majority more than half of the total votes the candidate with the fewest votes E is eliminated. Their votes are then redistributed to the remaining candidates based on the next available choice on each ballot:
The voters who ranked E first now have their votes redistributed to D
C has votes and it is eliminated. The voters who ranked C B D A E now have their votes redistributed to B
The voters who ranked B C A D E already have their votes counted for B
After redistributing the votes, the tallies are:
A: votes
B: votes
C: votes
D: votes
E: votes
D now has the fewest number of votes and is eliminated. The voters who rank D E C B A now have their votes redistributed to B
Final counts: A: B: C: D: E:
Now, B has the most votes out of remaining votes after eliminating D so B wins the election.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
