Voting Program Activity

From Foss2Serve
(Difference between revisions)
Jump to: navigation, search
m (Background:)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{| border="1"
+
__NOTOC__
|-
+
 
|'''Title''' || Voting Program Assignment
+
{{Learning Activity Overview
|-
+
|title=
|'''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.
+
Voting Program Assignment
|-
+
|overview=
|'''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.
+
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 [https://www.ushahidi.com/about 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.
|-
+
|prerequisites=
|'''Learning Objectives''' || Students will demonstrate:
+
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.
 +
|objectives=
 
* if/else statements
 
* if/else statements
 
* relational operators
 
* relational operators
Line 15: Line 16:
 
* incremental development
 
* incremental development
 
* basic version control skills
 
* basic version control skills
|}
+
|process skills=
 +
}}
  
 
=== Background ===
 
=== Background ===
 +
 
'''Motivational Background Material'''
 
'''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.
+
: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 [https://www.ushahidi.com/about Ushahidi] develops crowdsourcing tools and began in response to post-election violence in Kenya in 2008. [https://en.wikipedia.org/wiki/Electronic_voting Electronic voting] in general and how those systems are implemented is an ever-expanding effort and discussion in the computing community.
  
 
'''Programming Background Material'''
 
'''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.
+
: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 [http://www.greenteapress.com/thinkapjava/thinkapjava.pdf Think Java: How to Think Like a Computer Scientist] by Allen Downey and Chris Mayfield.
  
 
'''Version Control Background Material'''
 
'''Version Control Background Material'''
 
:Basic information on version control such as that provided in the following Activities is recommended:
 
:Basic information on version control such as that provided in the following Activities is recommended:
  
:*[https://www.dropbox.com/sh/isyl5tx9lecfevi/AADYVaDsf7chYTKaWECHIi1ja/SE_VER%20-%20version%20control.pdf?dl=0 POGIL Activity on version control]
+
:*[[Version Control (Activity)]]
:*[http://foss2serve.org/index.php/Git:_Git_Intro_Activity Intro to Git Activity]
+
:*[[Git: Git Intro Activity]]
 
:*[https://help.github.com/articles/set-up-git/ GitHub Tutorial(s)]
 
:*[https://help.github.com/articles/set-up-git/ GitHub Tutorial(s)]
  
Line 35: Line 38:
 
It is very helpful to implement the assignment yourself ahead of time to make sure you understand the scaffolding rationale behind the individual deliverables.
 
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: ===
+
=== 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.
 
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.
  
{| border="1" class="wikitable"
+
{| class="wikitable"
 
! Voting Method
 
! Voting Method
 
! Short Description
 
! Short Description
Line 45: Line 49:
  
 
|-
 
|-
| '''Highest Number of Votes'''
+
| '''Highest Number of Votes (Popular Vote)'''
 
| Candidate with the highest number of votes wins
 
| Candidate with the highest number of votes wins
 
| [https://en.wikipedia.org/wiki/First-past-the-post_voting First-Past-The-Post Voting]
 
| [https://en.wikipedia.org/wiki/First-past-the-post_voting First-Past-The-Post Voting]
| United States - most state voting
+
| United States - most state electoral votes
  
 
|-
 
|-
 
| '''Absolute Majority'''
 
| '''Absolute Majority'''
| Candidate with the most number of votes wins with only
+
| Candidate with the most number of votes wins but only if they have the majority of all votes
|  
+
| [https://en.wikipedia.org/wiki/Supermajority#Majority_of_the_entire_membership Wikipedia link]
|
+
| [https://en.wikipedia.org/wiki/European_Parliament European Parliament]
  
 
|-
 
|-
 
| ''' Two-Round Highest Number of Votes'''
 
| ''' 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
|  
+
| [https://en.wikipedia.org/wiki/Two-round_system Wikipedia link]
|
+
| [https://en.wikipedia.org/wiki/Elections_in_Brazil#The_Brazilian_voting_machines Brazilian Elections]
 
|-
 
|-
 
| '''Electoral Highest Number of Votes'''
 
| '''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.
|  
+
| [http://www.diffen.com/difference/Electoral_Vote_vs_Popular_Vote Comparison of Electoral vs. Popular Vote]
|
+
| [https://en.wikipedia.org/wiki/Electoral_College_(United_States) United States Electoral College]
  
 
|-
 
|-
 
| '''Cumulative Voting'''
 
| '''Cumulative Voting'''
|  
+
| Candidates are elected in a single round of voting, but voters are given a set number of candidates they can give votes
|  
+
| [https://en.wikipedia.org/wiki/Cumulative_voting Wikipedia link on equal and even cumulative voting]
|  
+
| [https://en.wikipedia.org/wiki/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
  
  
=== Deliverables: ===
+
== Notes for Instructors ==
What will the student hand in?
+
  
=== Assessment: ===
+
=== Assessment ===
How will the activity be graded?
+
* 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%
 
   
 
   
How will learning will be measured?
+
* 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%
  
Include sample assessment questions/rubrics.
+
* 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%
  
{| border="1" class="wikitable"
+
{| class="wikitable"
 
! Criteria
 
! Criteria
 
! Level 1 (fail)
 
! Level 1 (fail)
Line 93: Line 133:
 
! Level 3 (good)
 
! Level 3 (good)
 
! Level 4 (exceptional)
 
! Level 4 (exceptional)
 +
 
|-
 
|-
| '''Criterion 1...'''
+
| '''Commit %'''
|  
+
| No commits
|  
+
| One incomplete commit
|
+
| Two commits, but incomplete
|
+
| Two complete commits
  
 
|-
 
|-
| '''Criterion 2...'''
+
| '''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
  
=== Comments: ===
+
|-
What should the instructor know before using this activity?
+
| '''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
  
What are some likely difficulties that an instructor may encounter using this activity?
 
  
=== Additional Information: ===
 
{| border="1"
 
|-
 
|'''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
+
| '''Student Test Cases'''
|-
+
| less than 50% of faculty test categories covered by student
|'''Level of Difficulty''' || Is this activity easy, medium or challenging?
+
| 70% of faculty test cases categories covered by student
|-
+
| 80% of faculty test cases categories covered by student
|'''Estimated Time to Completion''' ||  How long should it take for the student to complete the activity?
+
| all faculty test cases categories covered by student
|-
+
 
|'''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/)
+
| '''Resolved all indicated issues'''
 +
| less than 50% of issues
 +
| 70% of issues
 +
| 80% of issues
 +
| all issues
 
|}
 
|}
  
=== Suggestions for Open Source Community: ===
+
=== Comments ===
Suggestions for an open source community member who is working in conjunction with the instructor.
+
N/A
  
--------------------
+
=== Suggestions for Open Source Community ===
This work is licensed under a
+
''Suggestions for an open source community member who is working in conjunction with the instructor.''
[http://creativecommons.org/licenses/by-sa/4.0/ Creative Commons Attribution-ShareAlike 4.0 International License]
+
  
[[File:CC_license.png]]
+
=== Additional Information ===
  
[[Category: Learning_Activity]]
+
{{Learning Activity Info
[[Category: LEARNING_ACTIVITY_SUBCATEGORY]]
+
|acm unit=
 +
|acm topic=
 +
|difficulty=
 +
|time=
 +
|environment=
 +
|author=
 +
Dee Weikle
 +
|source=
 +
Dee Weikle
 +
|license=
 +
{{License CC BY SA}}
 +
}}
  
[[Category: CS1]]
+
[[Category:Learning Activity]]
[[Category: CS2]]
+
[[Category:Coding and Style]]
 +
[[Category:CS1]]
 +
[[Category:CS2]]
 +
[[Category:Ushahidi]]
 +
[[Category:Good Draft]]

Latest revision as of 12:44, 8 September 2018


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.

Prerequisites

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
After successfully completing this activity, the learner should be able to:
  • if/else statements
  • relational operators
  • logical operators
  • multiple methods
  • testing coverage
  • incremental development
  • basic version control skills
Process Skills
Practiced


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


Notes for Instructors

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

N/A

Suggestions for Open Source Community

Suggestions for an open source community member who is working in conjunction with the instructor.

Additional Information

ACM BoK
Area & Unit(s)
ACM BoK
Topic(s)
Difficulty
Estimated Time
to Complete
Environment /
Materials
Author(s)

Dee Weikle

Source

Dee Weikle

License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

CC license.png

Personal tools
Namespaces
Variants
Actions
Events
Learning Resources
HFOSS Projects
Evaluation
Navigation
Toolbox