Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 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 of the total number of original ballots not just 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started