Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You may also want to watch this short video (it's 1 minute:10 seconds long) that shows a quick example of ranked choice voting G What

image text in transcribed

You may also want to watch this short video (it's 1 minute:10 seconds long) that shows a quick example of ranked choice voting G What you need to do: You're going to extend the ranked choice voting case study to allow for incomplete preferences. Voters are normally allowed to fill out the ballot in an incomplete manner. For example, with the sample ballots with four candidates, you might have ballots that specify only a first choice or only two choices. When you have partial information, you can end up with empty ballots because the voter might have chosen candidates who are all eliminated. This will be represented in the input files by having lines that end before listing all the candidates. Using the example from the textbook, if there are four candidates (named "A", "B", "C", and "D") then a person who wants to vote for C and then A (but not for B or D ) would have a line in the input file that looks like: In order to accomplish this you will need to modify the program in the following ways: - Notice that this version, unlike the version in the book, will keep asking the user for a file (and then process the ballots in that file) until the user types in "quit" (which will cause the program to end instead of processing any more files). - Modify the Ballot class to have an isEmpty method that returns true when this ballot has no candidates left (it should return false if the ballot still has 1 or more candidates left) - Modify the Ballot.getCandidate() method to return "none" when the ballot has no candidates left - Then modify the TallyVotes program to account for potentially empty ballots. - It is possible that the input file will contain blank lines because a voter didn't pick any candidates, so include a test that ignores blank lines in the input file. - Modify the method that eliminates candidates so that it removes from the list of ballots any ballots that become empty. (That way the percentages will be reported correctly on the next round of tallying) - Remember that the winner must get 50%+1 of the total number of original ballots (not just 50% of the most recent round). You will need to modify the code so that the original number of ballots is used to calculate the winner

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

4. Does cultural aptitude impact ones emotional intelligence?

Answered: 1 week ago