Voting Program Activity
Title | Voting Program Assignment |
Overview | The student will write a program that will implement 5 different voting strategies in individual methods motivated by exposure to the humanitarian open-source project Ushahidi and general election results. The activity as presented makes use of the version control systems git and GitHub to encourage incremental software development, unit testing and documentation. |
Prerequisite Knowledge | Students should have basic knowledge in a programming language of choice (here Java is used) including variables, types, assignment, arithmetic operators, standard i/o, and selection. Students should also have basic knowledge in using version control software as an individual for backups and versions. |
Learning Objectives | Students will demonstrate:
|
Contents |
Background
Motivational Background Material
- Democratic countries such as the United States place a high value on representative government and the fair election of government officials. Inexperienced individuals often assume that elections are won by a simple majority. While this is true in some instances, there are many examples even beyond the federal election of President in the United States where other voting methods are used. In addition, to have a fair election votes must be cast and counted accurately and without undue influence on voters. Technology and computing is involved in many aspects of elections and voting in around the world. The humanitarian open source software project Ushahidi develops crowdsourcing tools and began in response to post-election violence in Kenya in 2008. Electronic voting in general and how those systems are implemented is an ever-expanding effort and discussion in the computing community.
Programming Background Material
- Basic knowledge in how to write a program and introductory material in a programming language of choice is required. An example of the level of material required would be Chapters 1-5 of Think Java: How to Think Like a Computer Scientist by Allen Downey and Chris Mayfield.
Version Control Background Material
- Basic information on version control such as that provided in the following Activities is recommended:
The rationale for this activity is to bring a social context and open source revision management exposure into a fairly traditional introductory course assignment in such a way that it meets the needs of the introductory course and begin to establish good software engineering habits in addition to providing a vision of what computing skills can be applied to in the real world.
It is very helpful to implement the assignment yourself ahead of time to make sure you understand the scaffolding rationale behind the individual deliverables.
Directions:
You will be implementing several voting methods used in different levels of government and determining the winner of an election for these different methods. Below is a table of the different voting methods you will implement.
Voting Method | Short Description | Link to Background/Detailed Explanation | Example of Use |
---|---|---|---|
Highest Number of Votes (Popular Vote) | Candidate with the highest number of votes wins | First-Past-The-Post Voting | United States - most state electoral votes |
Absolute Majority | Candidate with the most number of votes wins but only if they have the majority of all votes | Wikipedia link | European Parliament |
Two-Round Highest Number of Votes | Voting happens in two-rounds. All candidates are in the first round - two candidates with highest number of votes then have two-person race in second round to determine winner | Wikipedia link | Brazilian Elections |
Electoral Highest Number of Votes | Voters are separated into groups that have a certain number of votes (electors) and all of the votes of a group are awarded to the candidate with a majority of the votes from that group. The the candidate with the majority of the electors (group votes) win. | Comparison of Electoral vs. Popular Vote | United States Electoral College |
Cumulative Voting | Candidates are elected in a single round of voting, but voters are given a set number of candidates they can give votes | Wikipedia link on equal and even cumulative voting | Peoria, Illinois
|
By the end of this programming assignment, you will have implemented the method calculateVote prompting a user for what voting method they want to use and one method that calculates each individual voting strategy, named as follows:
- int calculatePop() - returns the integer associated with the candidate that would win the election if it were run using a strict popular vote, returns -1 if there i no winner
- int calculateAbsMaj() - returns the integer associated with the candidate that would win the election if it were run using an absolute majority, returns -1 if there is no winner
- int calculateTwoPop() - returns the integer associated with the candidate that would win the election if it were run using a two-round strict popular vote (highest number of votes wins), returns -1 if there is no winner
- int calculateElecPop() - returns the integer associated with the candidate that would win the election if it were run using an electoral vote with 4 electoral groups, returns -1 if there is no winner
- int calculateCumulative() - returns the integer associated with the candidate that would win the election if it were run using a cumulative voting method, returns -1 if there is no winner
Each of the above methods can be implemented without using iterative programming techniques. Because you are still learning how to handle all but the simplest data, the following methods will be provided:
- int totalVotes() - returns the total number of votes in the current election
- int voteCount(int candidateNum) - returns the raw number of votes cast in the current election for the candidate indicated by candidateNum
- int voteCount(int candidateNum, int electoralGroup) - returns the number of votes cast in the current election for the candidate indicated by candidateNum for the electoral group indicated by electoralGroup
Note that for the purpose of this assignment, each election will have a total of 7 candidates, numbered 0-6 and a total of 4 electoral groups numbered 0-3.
Deliverables:
The student will have a total of 3 due dates:
- Due date 1: GitHub repository will have had pull request from professor for assignment and a minimum of two commits after which the calculateVote method is calling stub routines of each of the 5 calculate methods
- Due date 2: GitHub repository will have had an additional two commits after which the calculatePop(), calculateTwoPop(), and calculateCumulative() are implemented fully
- Due date 3: GitHub repository will have had an additional two commits after which all methods will be implemented
Assessment:
- Due date 1:
- Correct number of commits - 10%
- JavaDoc comments on required implementation - 10%
- Passes Checkstyle or equivalent style guide - 10%
- Correct implementation on required code - 60%
- Appropriate test cases for required code - 10%
- Due date 2:
- Correct number of commits - 5%
- JavaDoc comments on required implementation - 10%
- Passes Checkstyle or equivalent style guide - 10%
- Correct implementation on required code - 60%
- Appropriate test cases for required code - 10%
- Resolved issues as indicated on response to due date 1 - 5%
- Due date 3:
- Correct number of commits - 5%
- JavaDoc comments on required implementation - 10%
- Passes Checkstyle or equivalent style guide - 10%
- Correct implementation on required code - 60%
- Appropriate test cases for required code - 10%
- Resolved issues as indicated on response to due date 2 - 5%
Criteria | Level 1 (fail) | Level 2 (pass) | Level 3 (good) | Level 4 (exceptional) |
---|---|---|---|---|
Commit % | No commits | One incomplete commit | Two commits, but incomplete | Two complete commits |
JavaDoc comments | non-existent or few poorly written comments | not all comments included, but those that are are correctly written | all comments included, most correctly written | all comments included and correctly written |
Style Issues | fewer than half of the style guidelines are followed | 70% of style guidelines are followed, code is readable | 85% of style guidelines are followed, few noticeable mistakes | no style mistakes according to course style guidelines |
Correctness | less than 50% of faculty test cases covered | 70% of faculty test cases covered | 80% of faculty test cases covered | all faculty test cases covered
|
Student Test Cases | less than 50% of faculty test categories covered by student | 70% of faculty test cases categories covered by student | 80% of faculty test cases categories covered by student | all faculty test cases categories covered by student |
Resolved all indicated issues | less than 50% of issues | 70% of issues | 80% of issues | all issues |
Comments:
What should the instructor know before using this activity?
What are some likely difficulties that an instructor may encounter using this activity?
Additional Information:
ACM Knowledge Area/Knowledge Unit | What ACM Computing Curricula 2013 knowledge area and units does this activity cover? ACM_Body_of_Knowledge |
ACM Topic | What specific topics are addressed? The Computing Curriucula 2013 provides a list of topics - https://www.acm.org/education/CS2013-final-report.pdf |
Level of Difficulty | Is this activity easy, medium or challenging? |
Estimated Time to Completion | How long should it take for the student to complete the activity? |
Materials/Environment | What does the student need? Internet access, IRC client, Git Hub account, LINUX machine, etc.? |
Author(s) | Who wrote this activity? |
Source | Is there another activity on which this activity is based? If so, please provide a link to the original resource. |
License | Under which license is this material made available? (http://creativecommons.org/licenses/) |
Suggestions for Open Source Community:
Suggestions for an open source community member who is working in conjunction with the instructor.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License