Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use public class Multiple Winner Election Throughout this lesson, users will construct three techniques to compute the distribution of seats to the parties based on

Use public class Multiple Winner Election

Throughout this lesson, users will construct three techniques to compute the distribution of seats to the parties based on the votes collected by these parties. The procedures of D'Hondt, Webster, and Imperiali, which are all variants of the highest averages approach, are basically identical, but employ a different formula to determine the priority quantity for each party, as shown below. As a result, you could choose to construct the complete voting procedure as a single private method to which the next three public methods pass the buck.

 

public static int[] DHondt(int[] votes, int seats)

public static int[] webster(int[] votes, int seats)

public static int[] imperiali(int[] votes, int seats)

 

 

The parameter array votes indicates how many votes each party earned. The seats are distributed one at a time, such that each seat goes to the party with the highest priority at the moment. To ensure that the results are unambiguous for the JUnit fuzz tests, any ties should be resolved in favour of the party with the greater number, as in the previous "Preferential Voting" lab. In the D'Hondt method, the priority quantity of the party that obtained v votes and has thus far received s seats is v/(s+1), in the Webster approach, it is v/(2s+1), and in the Imperiali method, it is v/(1+s/2). With the Fraction data type, perform all computations with accurate integer arithmetic.

 

 

The returned result should be an int[] of the same length as the provided array votes, with each element showing how many seats that party received. For example, in a four-party election with seats=21 and votes=23,26,115,128, the D'Hondt method would yield 1,2,8,10, the Webster method would return 2,2,8,9, and the Imperiali approach would return 1,1,9,10. These findings show how changing the divisor sequence in the priority quantity computation can lead the process to favour bigger or smaller parties, with the Webster technique favouring larger parties and the Imperiali method favouring smaller parties the least.

 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres the implementation of the MultipleWinnerElection class with methods for DHondt Webster and Imperiali procedures public class MultipleWinnerElect... 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

International Marketing And Export Management

Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr

8th Edition

1292016922, 978-1292016924

More Books

Students also viewed these Programming questions