Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 12 Weeks Ago, 6 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Assignment 6 -- Voter Participation Data
Instructions: For this assignment, you will write a program that reads voter participation data from a file and processes that data in several different ways, including writing a report to a different file.
Data File Format
1952 |
The voter participation data we will work with is stored in a simple text file. Each line of the file contains one of 4 different things:
The file format is highly structured. Years are listed in order. On the line after each year is the estimated number of eligible voters for that year. On the next line is the number of registered voters for that year. On the next line is the number of ballots cast for that year. This sequence is repeated for each year. The first two years of data from one of the sample files are shown at right to illustrate this. Here are links to two sample files: PresidentialElections.txt  MidTermElections.txt [Data source: http://www.sos.wa.gov/elections/voter_participation.aspx (Links to an external site.)]
Program Specification
Write a program that does the following:
In 1952, 90.81% registered and 72.80% voted. In 1956, 89.45% registered and 71.75% voted. ... |
Here is an example of what the report would look like for the first file:
The total number of years listed: 17 Total ballots cast in all these years: 34,436,792 Average percentage of eligible voters registered: 79.55% Number of years with less than 60% of registered voters casting ballots: 0 Percentage of years with more than 80% of registered voters casting ballots: 47.1% An output file named REPORT-PresidentialElections.txt has been created. |
Development Tips:
Testing -- Be sure to carefully test your program with different files. You can create a simple, short file to make testing easy. As always, be sure to document your testing in comments at the end of the program. Your comments should also say if you think any part of the assignment requirements have not been met.Â
GradingÂ
/10 correctly determines 5 quantities to be shown in the shell window: # years, # ballots counted, average percentage of eligible voters who registered, <60% years and >80% years
/12 reads and writes files properly (reads data, writes out a report file, closes files, no errors)
/3 documented test casesÂ
/5 proper comments; good variable names; declarations; indenting; blank lines