As always, put your Assignment number, name, and class section in a block comment at the beginning of your code. Assignments missing this information will not be graded. Write a Voting Machine class that: . Accepts votes and voter IDs, one at a time, for each of two candidates Accumulates the number of votes for each of the two candidates Keeps track of voter IDs Reports out candidate votes and voter IDs Write another class with a main method that creates two instances of the Voting Machine, sends a sequence of votes and voter IDs to both instances, and then prints out a list of voter IDs, the total number of votes cast, and the vote totals for each of the two candidates. Details: The Voting Machine class should specify: • Two private variables to keep track of the number of votes for two candidates. A private variable to keep a list of all the voter IDs. Two methods, one for each candidate, that: Accept a voterID as input o Increment an internal vote counter for the candidate Concatenate the voterID to a string of voterIDs with the voterIDs separated by spaces. Use the String concat method to accomplish this. • Two accessor methods, one for each candidate, that return the number of votes recorded for the candidate • An accessor method that returns the voterlDs Be sure to comment your Voting Machine class and its methods appropriately such that javadoc could generate documentation. Your main method in Assignment03 should contain the following lines which cast votes for two candidates on two different voting machines. The voting machines are vm1 and vm2. The votes are cast by calling either voteForCandidate1 or voteForCandidate2. The argument sent to the voting methods is the voterID:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Honestly, I am struggling with my assignment here. I went to the teaching assistants and they told me that they still too are working through this problem. its harder to implement because I am a visual learner. 

 

import java.util.Scanner;

 

public class Assignment03

{

   public static void main(String[] args)

   {

      

      Scanner keyboard = new Scanner(System.in);

      System.out.println("Voter ID List: ");

      String voterId = keyboard.nextLine();

      

      System.out.println("Total number of votes: ");

      int totalVotes = keyboard.nextInt();

      

      System.out.println("Votes for candidate 1: ");

      int candidate1Votes = keyboard.nextInt();

      

      System.out.println("Votes for candidate 2: ");

      int candidate2Votes = keyboard.nextInt();

      

      keyboard.close();

   }

}

//Votes on the first voting machine
vml.voteForCandidatel ("HL76983");
vm1.voteForCandidate2 ("HL17522");
vm1.voteForCandidatel ("HL32437");
vm1.voteForCandidatel ("HL02845");
vml.voteForCandidatel ("HL32710");
vm1.voteForCandidate2 ("HL39835");
//Votes on the second voting machine
vm2.voteForCandidate2 ("HL93952");
vm2.voteForCandidatel ("HL38385");
vm2.voteForCandidate2 ("HL90310");
vm2.voteForCandidate2 ("HL59293");
vm2.voteForCandidate2 ("HL32346");
Before these lines, you need to create the two voting machine instances. (You might also declare any variables you use later.) After these lines, you
need to write print statements (maybe mixed with others) to produce the following output:
Voter ID List: HL76983 HL17522 HL32437 HL02845 HL32710 HL39835 HL93952 HL90310 HL59293 HL32346 HL38385
Total number of votes: 11
Votes for candidate 1: 5
Votes for candidate 2: 6
The values in the output must be generated by calling accessor methods on the voting machine instances. You can call the methods directly
within the print statements or assign their values to variables and use the variables in the print statements.
Transcribed Image Text://Votes on the first voting machine vml.voteForCandidatel ("HL76983"); vm1.voteForCandidate2 ("HL17522"); vm1.voteForCandidatel ("HL32437"); vm1.voteForCandidatel ("HL02845"); vml.voteForCandidatel ("HL32710"); vm1.voteForCandidate2 ("HL39835"); //Votes on the second voting machine vm2.voteForCandidate2 ("HL93952"); vm2.voteForCandidatel ("HL38385"); vm2.voteForCandidate2 ("HL90310"); vm2.voteForCandidate2 ("HL59293"); vm2.voteForCandidate2 ("HL32346"); Before these lines, you need to create the two voting machine instances. (You might also declare any variables you use later.) After these lines, you need to write print statements (maybe mixed with others) to produce the following output: Voter ID List: HL76983 HL17522 HL32437 HL02845 HL32710 HL39835 HL93952 HL90310 HL59293 HL32346 HL38385 Total number of votes: 11 Votes for candidate 1: 5 Votes for candidate 2: 6 The values in the output must be generated by calling accessor methods on the voting machine instances. You can call the methods directly within the print statements or assign their values to variables and use the variables in the print statements.
In JDoodle, create a class called Assignment03.
As always, put your Assignment number, name, and class section in a block comment at the beginning of your code. Assignments missing this
information will not be graded.
Write a Voting Machine class that:
• Accepts votes and voter IDs, one at a time, for each of two candidates.
• Accumulates the number of votes for each of the two candidates
Keeps track of voter IDs
• Reports out candidate votes and voter IDs
Write another class with a main method that creates two instances of the Voting Machine, sends a sequence of votes and voter IDs to both
instances, and then prints out a list of voter IDs, the total number of votes cast, and the vote totals for each of the two candidates.
Details:
The Voting Machine class should specify:
• Two private variables to keep track of the number of votes for two candidates.
• A private variable to keep a list of all the voter IDs.
Two methods, one for each candidate, that:
• Accept a voterID as input
o Increment an internal vote counter for the candidate
• Concatenate the voterID to a string of voterIDs with the voterIDs separated by spaces. Use the String concat method to accomplish this.
• Two accessor methods, one for each candidate, that return the number of votes recorded for the candidate
• An accessor method that returns the voterlDs
Be sure to comment your Voting Machine class and its methods appropriately such that javadoc could generate documentation.
Your main method in Assignment03 should contain the following lines which cast votes for two candidates on two different voting machines. The
voting machines are vm1 and vm2. The votes are cast by calling either voteForCandidate1 or voteForCandidate2. The argument sent to the
voting methods is the voterID:
Transcribed Image Text:In JDoodle, create a class called Assignment03. As always, put your Assignment number, name, and class section in a block comment at the beginning of your code. Assignments missing this information will not be graded. Write a Voting Machine class that: • Accepts votes and voter IDs, one at a time, for each of two candidates. • Accumulates the number of votes for each of the two candidates Keeps track of voter IDs • Reports out candidate votes and voter IDs Write another class with a main method that creates two instances of the Voting Machine, sends a sequence of votes and voter IDs to both instances, and then prints out a list of voter IDs, the total number of votes cast, and the vote totals for each of the two candidates. Details: The Voting Machine class should specify: • Two private variables to keep track of the number of votes for two candidates. • A private variable to keep a list of all the voter IDs. Two methods, one for each candidate, that: • Accept a voterID as input o Increment an internal vote counter for the candidate • Concatenate the voterID to a string of voterIDs with the voterIDs separated by spaces. Use the String concat method to accomplish this. • Two accessor methods, one for each candidate, that return the number of votes recorded for the candidate • An accessor method that returns the voterlDs Be sure to comment your Voting Machine class and its methods appropriately such that javadoc could generate documentation. Your main method in Assignment03 should contain the following lines which cast votes for two candidates on two different voting machines. The voting machines are vm1 and vm2. The votes are cast by calling either voteForCandidate1 or voteForCandidate2. The argument sent to the voting methods is the voterID:
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY