Java Reference
In-Depth Information
votes.txt , contains the names of the candidates. The first name is considered as
candidate 1, the second as candidate 2, and so on. The names are followed by the votes. Write
a program to read the data and evaluate the results of the election. Print all output to the file
results.txt .
Your output should specify the total number of votes, the number of valid votes, and the
A file,
number of spoiled votes. This is followed by the votes obtained by each candidate and the
winner(s) of the election.
Given this data in votes.txt :
Nirvan Singh
Denise Duncan
Avasa Tawari
Torrique Granger
Saskia Kalicharan
Dawren Greenidge
Jordon Cato
3 1 6 5 4 3 5 3 5 3 2 8 1 6 7 7 3 5
6 9 3 4 7 1 2 4 5 5 1 4 0
your program should send the following output to results.txt :
Invalid vote: 8
Invalid vote: 9
Number of voters: 30
Number of valid votes: 28
Number of spoilt votes: 2
Candidate Score
Nirvan Singh 4
Denise Duncan 2
Avasa Tawari 6
Torrique Granger 4
Saskia Kalicharan 6
Dawren Greenidge 3
Jordon Cato 3
The winner(s)
Avasa Tawari
Saskia Kalicharan
We will use the following outline for solving this problem:
get the names and set the scores to 0
process the votes
print the results
 
Search WWH ::




Custom Search