Election Calculator

This simple election calculator, the courtesy of A. Yavuz Oruc and JavaScript computes the number of seats won by a political party in a parliamentary election. It uses the D'Hondt's electoral system where the votes of only those political parties that receive at least a threshold percentage of the valid votes are taken into account. For example, if parties, A, B, C, D, and E participate in the election and receive 40%, 30%, 18% , 8%, and 4% of the votes in an election region that is slated to have 8 seats in the parliament and there is a 10% threshold then the following simple computation is carried out: The votes of A, B, and C are divided by 1, 2, 3,...,8 and the highest eight counts of votes win the eight seats. (Parties D and E do not win any seats because of the 10% threshold.)

Party
D'Hondt's Method
Seats Won
A
40(1)
20(3)
13.33(6)
10(8)
8
6.67
5.71
5
4
B
30(2)
15(5)
10(7)
7.5
6
5
4.5
3.75
3
C
18 (4)
9
6
4.5
3.6
3
2.57
2.25
1

Here is how the calculator works:

1. Enter the votes of the parties in whole numbers such as 2345, 120, 5672, 934562 without using any spaces or commas into the text fields across the party amblems.

2. Enter the threshold, if any, as a percentage. You can enter any number between 0 and 100. This should be useful when you want to exclude a particular party with the least percentage of votes from winning any seats. You can also enter 0 in the number of votes row for any particular party that falls below the required threshold. That is, if you would like to assume that a party gathers less than the threshold over all the election districts then you should enter 0 in an estimation of the number of seats for that party in any district.

3. Enter the number of seats to be contested..

4. Click once over the % virtual key if you would like to view the votes in percentages.

5. Click once over the SEATS key to see the distribution of seats among the parties.

Note-1: You can use your keyboard keys to directly fill out the text fields.

Note-2: In some pathological cases, the number of seats may be distributed unevently. For example, all five parties receive 20% of the votes, but there are only 4 seats to be won. In such a case one party goes without a seat. The implementation of Dhondt's algorithm is simplified to avoid excessive use of memory, especially when there are too many seats. Thus, rather than computing all the quotients of the numbers of votes by 1,2,3, etc., this is done gradually and selectively, and this way, the size of the arrays is limited to the number of parties rather than the number of seats that is generally greater than the number of parties.

Parties
Votes
%
Seats
A
B
C
D
E
F
G
H
Others
Total
Threshold(%):
Seat Count:

 

   
A. Yavuz Oruç © 2015, All rights reserved.