CPSC 170 PostLab 0: Voting Stations
In SmallTown, USA, there is fierce competition among the voting stations
to see who has the best turnout for big elections. Write a program that
asks the user how many voting stations there are, then prompts for and
reads in the number of votes cast at each station. The stations should
be numbered starting at 1. Then do the following:
- Compute and print the number of votes cast at the odd-numbered stations.
- Compute and print the number of votes cast at the even-numbered stations.
- Print a message indicating whether the even or odd stations had the
best turnout.
- Ask the user for two station numbers and print the total number of votes
cast at those two stations and all stations in between. If the
first station number is greater than the second one, the result
should
just be 0 votes. Allow the user to repeat this as often as they wish.
A run of your program might look like this:
How many polling stations are there?
6
Enter votes for station 1: 10
Enter votes for station 2: 9
Enter votes for station 3: 15
Enter votes for station 4: 13
Enter votes for station 5: 22
Enter votes for station 6: 18
Sum of even stations: 40
Sum of odd stations: 47
Odd beats even!
** Totaling ranges of stations **
Enter first station number: 1
Enter second station number: 4
Sum for stations 1 to 4 is 47
Keep going? (y/n)
y
Enter first station number: 4
Enter second station number: 5
Sum for stations 4 to 5 is 35
Keep going? (y/n)
y
Enter first station number: 3
Enter second station number: 2
Sum for stations 3 to 2 is 0
Keep going? (y/n)
n
Bye!
Be sure to document your program appropriately.
Turn in hardcopy of Votes.java and e-mail the .java file to me.
Be sure to put cpsc170 post0 in the Subject line.