In JDoodle, create a class called Assignment03. As always, put your Assignment number, name, and class...
Fantastic news! We've Found the answer you've been seeking!
Question:
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 VotingMachine 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 • 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 voterIDs 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 voteForCandidate 1 or voteForCandidate 2. The argument sent to the voting methods is the voterID: //votes on the first voting machine vml.voteForCandidatel ("HL76983"); vm1.voteForCandidate 2 ("HL17522"); vml.voteForCandidatel ("HL32437"); vm1.voteForCandidatel ("HL02845"); vml.voteForCandidatel ("HL32710"); vm1.voteForCandidate 2 ("HL39835"); //Votes on the second voting machine vm2.voteForCandidate2 ("HL93952"); vm2.voteForCandidatel ("HL38385"); vm2.voteForCandidate 2 ("HL90310"); vm2.voteForCandidate 2 ("HL59293"); vm2.voteForCandidate 2 ("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 VotingMachine 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 • 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 voterIDs 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 voteForCandidate 1 or voteForCandidate 2. The argument sent to the voting methods is the voterID: //votes on the first voting machine vml.voteForCandidatel ("HL76983"); vm1.voteForCandidate 2 ("HL17522"); vml.voteForCandidatel ("HL32437"); vm1.voteForCandidatel ("HL02845"); vml.voteForCandidatel ("HL32710"); vm1.voteForCandidate 2 ("HL39835"); //Votes on the second voting machine vm2.voteForCandidate2 ("HL93952"); vm2.voteForCandidatel ("HL38385"); vm2.voteForCandidate 2 ("HL90310"); vm2.voteForCandidate 2 ("HL59293"); vm2.voteForCandidate 2 ("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.
Expert Answer:
Answer rating: 100% (QA)
Below is the implementation of the Assignment03 class and the VotingMachine class in Java java Assignment 03 Voting Machine Class Section Your class s... View the full answer
Related Book For
Horngrens Financial and Managerial Accounting
ISBN: 978-0133866292
5th edition
Authors: Tracie L. Nobles, Brenda L. Mattison, Ella Mae Matsumura
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Financial statements for the ACTACTSTAT Company are given below: During 2021 the firm declared and paid cash dividends of P85,000. There were 50,000 shares of common stock outstanding throughout the...
-
Tony is a 45-year-old psychiatrist who has net earned income of $300,000 in 2016. What is the maximum amount he can contribute to his SEP for the year?
-
In Exercises 2944, perform the indicated operations and write the result in standard form. -15 V-18 V-18 - 33
-
What is the difference between a predator and a situational (accidental) fraudster?
-
Marie Janes encounters the following situations in doing the audit of a large auto dealership. Janes is not a partner. 1. The sales manager tells her that there is a sale (at a substantial discount)...
-
When President Obama was President he had discussed raising income taxes for individuals earning over $250,000 in income. Explain how these higher income taxes will affect the aggregate demand curve....
-
1. Criminal law: Police suspected that Adam Albert was growing marijuana in his personal residence. Using thermal heat detectors, they were able to detect unusual high levels of indoor temperature....
-
Award: 10.00 points 61. Award: 10.00 points An individual contributed $100,000 of cash and pledged another $50,000 to an NFPO to cover the $50,000 salary of its executive director for the current...
-
Patient volume and salaries are variable expenses that are hard to predict. Most urgent cares operate on incentive bonuses for providers, sick calls may require giving overtime to employees that are...
-
5 Woof pic manufactures one product, a luxury dog food which sells at 20. Calculate the following values from the last six months results ending 30 April: Month January February March April May June...
-
A company launched business App. For smart mobile phones, the users who installed the app. in 2 0 1 4 were 1 4 2 0 0 0 users, and they increase by 1 0 % each succeeding year. a ) Determine the number...
-
We talked about the Medicare "parts" or "plans" that cover different types of services, and how they are each separately funded. We also talked about when each is projected to be insolvent, in part...
-
A Kaplan turbine produces 44000 kW under a head of 24.7 m, with an overall efficiency of 90 per cent. Taking the value of speed ratio as 1.6, flow ratio as 0.5 and the hub diameter as 0.35 times the...
-
Solve each problem. Find the coordinates of the points of intersection of the line y = 2 and the circle with center at (4, 5) and radius 4.
-
Summer Company sells a product with a contribution margin ratio of 60%. Fixed costs are $650 per month. What amount of sales (in dollars) must Summer Company have to earn an operating income of...
-
Camron Company has divided its business into segments based on sales territories: East Coast, Midland, and West Coast. Following are financial data for 2016: Prepare an income statement for Camron...
-
Indicate the effects of the following business transactions on the accounting equation of Vivians Online Video store. Transaction (a) is answered as a guide. a. Received cash of $10,000 from issuance...
-
Figure 1.10 shows an automatic water level control system. (a) Explain how the automatic control system works indicating the roles of key components. (b) If the automatic water level control system...
-
Many closed-loop and open-loop control systems can be found in homes. (a) List six such examples (three open-loop and three closed-loop). (b) Construct feedback control system block diagrams for the...
-
The diagram depicted in Figure 1.38 is a closed-loop temperature control system. (a) Explain how this control system works. (b) If the automatic controller is replaced by manual control, explain how...
Study smarter with the SolutionInn App