Write a program using the bucket sort idea to create histograms of an election.
ID: 3641480 • Letter: W
Question
Write a program using the bucket sort idea to create histograms of an election.
•The input data are in an external file named election.txt. The first line is an integer N representing the number of candidates. The next N lines are the names of the canditates. The remaining lines are individual votes, each recorded as an integer from 0 to N-1 representing the number of one of the candidates, as in election.txt, below.
•The output for the above file should look like
Election Results
================
Albert *****
Ford ***
Harris ******
Jones ********
Smith ************
•For input from election.txt, put the following in a try{} block, and import java.io.*;
Scanner sc = new Scanner(new FileReader("election.txt"));
•If the Scanner is declared in a block, it cannot be referenced outside of the block.
•Remember, if sc is your Scanner, then you should always use sc.nextLine(); after each call to sc.nextInt() to clear the input buffer.
•You may assume that the input file is in the correct format.
Election.txt is listed below:
5
Albert
Ford
Harris
Jones
Smith
0
3
3
4
2
0
3
4
1
1
2
3
4
4
4
4
4
4
0
0
2
3
2
4
4
3
0
4
3
1
4
0
3
2
2
The code must be completed how i asked to get full points. The code must include a comment for each method describing the method, a comment for each parameter describing what the parameter represents, and a comment for each variable declaration (including instance variables) describing what the variable represents.