# Calculadora Escons: Calculate elected seats using D'Hondt method

 Last Updated Ratings Unique User Downloads Download Rankings 2007-07-01 (8 years ago) Not enough user ratings Total: 284 All time: 6,947 This week: 1,020
 Version License PHP version Categories calculadoraescons 1.1 GNU General Publi... 5.0 Algorithms
Description Author

This class can be used to calculate the number of seats assigned to a party upon election results using the D'Hondt method.

It takes as parameters the number of available seats and an associative array that relates each party with the votes they received.

The class distributes the available seats using the D'Hondt method and returns an associative arrays that relates each party with the number of assigned seats that they got.

The code and the comments are in Catalan.

 Innovation Award
 June 2007 Number 10 The D'Hondt method is used in many countries to calculate the number of seats assigned to a party, depending on the percentage of votes that they get in elections. This class provides an implementation of the D'Hondt method. It can be used by PHP sites that want to show on the Web the partial or final results of elections that take place on countries that use this method of assigning elected seats. Manuel Lemos
Name: Classes: Manel Zaera 3 packages by Manel Zaera Spain 41 2058 48 in Spain 1501 38 in Spain
Innovation award

Nominee: 1x

 Details
 ```CalculadoraEscons is a class that calculates the number of seats belonging to each party in an election process, using the D'Hondt's method. To use this class you have to: 1.- Create an object: \$aCalc = new CalculadoraEscons(); 2.- Call the class with the list of parties and votes collected by each of them, and the number of seats to distribute: \$aPartits = array('CiU' => 4367,'PSC' => 2252, 'ERC' => 2131,'ICV' => 403,'PP' => 287,'IPE' => 234); \$aEscons = \$aCalc->calcula(\$aPartits,17); The "calcula" method returns an array where the keys are the names of the parties and the values are the seats assigned to them. 2005-05-21, Manel Zaera CalculadoraEscons is free software released under the GNU GPL license, la qual podeu consultar a http://www.gnu.org/copyleft/gpl.html```
 Files
File Role Description