Voting Program Activity

From Foss2Serve
Revision as of 18:48, 16 August 2016 by Dee.weikle (Talk | contribs)
Jump to: navigation, search
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:
  • if/else statements
  • relational operators
  • logical operators
  • multiple methods
  • testing coverage
  • incremental development
  • basic version control skills



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 general. 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.


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:

  • calculatePop()
  • calculateAbsMaj()
  • calculateTwoPop()
  • calculateElecPop()
  • calculateCumulative()

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:

  • totalVotes() - returns the total number of votes in the current election
  • voteCount(int candidateNum) - returns the raw number of votes cast in the current election for the candidate indicated by candidateNum

Note that for the purpose of this assignment, each election will have a total of 7 candidates.


What will the student hand in?


How will the activity be graded?

How will learning will be measured?

Include sample assessment questions/rubrics.

Criteria Level 1 (fail) Level 2 (pass) Level 3 (good) Level 4 (exceptional)
Criterion 1...
Criterion 2...


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 -
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? (

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

CC license.png

Personal tools
Learning Resources
HFOSS Projects