Question: Voting Machine - A college would like to make an automatic voting system. The system will receive 3 candidates names and displays the name to
Voting Machine - A college would like to make an automatic voting system. The system will receive 3 candidates names and displays the name to the voters. Then each voter should enter one choice at a time 1, 2 or 3 subject to the number of candidates respectively. The system will calculate all choices made and will list up the result at the end of the voting session. Prior exit the system will display the result in a bar graph. """"" In Java""""


Enter candidates name (Ctrl-Z to end input candidates): Candidate 1 : Manal Candidate 2 : Khadijah Candidate 3: Wafa ^Z. End entering candidate Begin voting.. Time start: 12:00:00 (1) Manal: 0 (2) Khadijah:0 Your choice: 3 Next vote (y): Y (3) Wafa: 0 (3) Wafa:1 (1) Manal: 0 (2) Khadijah:0 Your choice: 3 Next vote (y): Y (3) Wafa:2 (1) Manal: 0 Your choice: (2) Khadijah:0 invalid choice (3) Wafa:2 (1) Manal: 0 (2) Khadijah: 0 Your choice: 3 Next vote (y): Y (3) Wafa:3 (1) Manal: 0 (2) Khadijah: 0 Your choice: 2 Next vote (y): Y (3) Wafa: 3 (1) Manal: 0 (2) Khadijah:1 Your choice: 2 Next vote (y): n (1) Manal: 0 (2) Khadijah:2 (3) Wafa:3 End Voting Session Time: 12:30:02 Final Result for Voting 1- Manal 2- Khadijah | ** 3- Manal *** Total voters: 5 Num a) Tips Declare a class Candidate in which will allow user to set name of every candidates and hold the status of ballot for a candidate. b) Deploy suitable constructor(s). Include in the class set and get methods. Extend with one additional method showBar() that can display in bar chart for a candidate based on votes collected. c) d) Write a program that can execute and manipulate the object variable of candidates as reflected in the screen. *Introduce an array of type Candidate in which can process candidate votes. Display a bar graph based on number of votes obtained during the voting session as reflected on the sample output. Refer Figure 1 to write the main program. f)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
