Using only LinkedList as only Data Structure to do the Ranked Voting Program. Must use this following main method:

public static void main(String[] args) {
List< Ballot > ballots = readFile();
displayBallotList(ballots);
List< Tally > tallies = new LinkedList< Tally >();
castBallots(tallies, ballots);

while( !haveWinner(tallies)) {
displayTallies(tallies);
Tally minTally = removeMinTally(tallies);
System.out.println(minTally.candidate+" was removed from the race.");
castBallotsAgain(tallies, minTally);
}
displayTallies(tallies);
}

Need to have Ballot class, Tally class with "candidate" non private field. A ballot has a list of String, one for each name on the ballot. A Tally has a list of ballot. No more than 2 loops in same method.

Here is how ranked voting works:

  • A ballot have one or more than one candidate ( 1 line in the ballot file)
  • In the first round, each ballot is put in different tally based on 1st choice only (same first choice, in same tally)
  • Tally with fewest ballots will be remove
  • After remove the first choice in those removed tally, the ballots in the removed Tally are "revoted." So after removing the first choice from those ballots, we try to add the ballot to the voter's second choice, or if that's not possible, to the voter's third choice, etc.
  • Continue removing tally until one of the remain has more than fifty percent vote.

Using only LinkedList as only Data Structure.

Output as console, like finaldisplay file.

ballots-input file is input file.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.