Java Reference
In-Depth Information
getCandidatesName(inFile, candidatesName);
//Step 3
sortCandidatesName(candidatesName);
//Step 4
inFile = null ;
inFile = new Scanner( new
FileReader("voteData.txt"));
//Step 5
processVotes(inFile, candidatesName,
votesByRegion);
//Step 6
addRegionsVote(votesByRegion, totalVotes);
//Step 7
printHeading();
//Step 8
printResults(candidatesName, votesByRegion,
totalVotes);
//Step 9
}
//Place the definitions of the methods getCandidatesName,
//sortCandidatesName, binSearch, processVotes,
//addRegionsVote, printHeading, and printResults,
//as described in this section, here.
}
Sample Run: (After placing the definitions of all the methods as described and then
executing the program, the output is as follows.)
---------------Election Results--------------
Candidate
Votes
Name
Region1 Region2 Region3 Region4
Total
----
------- ------- ------- -------
-----
Ashley
23
89
0
160
272
Danny
25
71
89
97
282
Donald
110
158
0
0
268
Mia
134
112
156
0
402
Mickey
56
63
67
89
275
Peter
207
56
0
46
309
Winner: Mia, Votes Received: 402
Total votes polled: 1808
Input Files : The files candData.txt and voteData.txt are provided with the
Additional Student Files at www.cengagebrain.com. The complete program listing of
this program can also be found in this folder.
1
4
The OOD version of this program can be found with the Additional Student Files at
www.cengagebrain.com. The name of the file containing the Programming Example
is Chapter 14_ElectionResults_ OOD_Version.pdf.
 
Search WWH ::




Custom Search