Write a program that will record the votes for one of two candidates by using the class VoteRecorder, which you will design and create. Vote Recorder will have static variables to keep track of the total votes for candidates and instance variables to keep track of the votes made by a single person. It will have the following attributes.
- nameCandidatePresident11—a static String that holds the name of the first candidate for president
- nameCandidatePresident2—a static string that holds the name of the second candidate for president
- nameCandidateVicePresident1 —a static string that holds the name of the first candidate for Vice president
- nameCandidateVicePresident2—a static string that holds the name of the second candidate for Vice president
- votesCondidatePresident1—a static integer that holds the number of votes for the first candidate for president
- votesCandidatePresident2—a static integer that holds the number of voles for the second candidate for president
- votesCandidateVicePresident1—a static integer that holds the number of votes for the first candidate for Vice president
- votesCandidateVicePresident2—a static integer that holds the number of rates for the second candidate for Vice president
- myVoteForPresident—an integer that holds the vote of a single individual for president (0 for no choice, 1 for the first candidate, and 2 for the second candidate)
- myVoteForVicePresident—an integer that holds the vote of a single individual for vice president (0 for no choice, 1 for the first candidate, and 2 for the second candidate)
In addition to appropriate constructors, VotRecorder has the following methods:
- setCandidaterPresident(String name1, String name2)—a static method that sets the names of the names of the two candidates for president
- getCandicateoVicePresident (String name1, string name2)—a static method that sets the names of the two candidates for vice president
- resetVotes—a static method that resets the vote counts to zero
- getCurrentVotePresident—a static method that returns a string with a current total number of votes for both presidential candidates
- getAndConfirmVotes—a non-static method that gets an individual’s votes, confirms then, and then records them
- getAVote(String name1, string name2)—a private method that returns a vote choice for a single race from a individual (0 for no choice, 1 for the first candidate, and 2 for the second candidate)
- getVotes—a private method that returns a vote choice for president and vice president from an individual
- confirmVotes—a private method that displays a person’s vote for president and vice president, asks whether the voter is happy with these choices, and returns true or false according to a yes-or-no response
- recordVotes—a private method that will add an individual’s votes to the appropriate static variables
Create a program that will candidates an election. The candidates for president are Annie and Bob. The candidates for vice president are John and Susan. Use a loop to record the votes of many voters. Create a new Vote Recorder object for each voter. After all the voters are done, present the results.
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Java: An Introduction To Problem Solving And Programming Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)
Additional Engineering Textbook Solutions
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Mechanics of Materials (10th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Modern Database Management
SURVEY OF OPERATING SYSTEMS
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- PLEASE SOLVE STEP BY STEP WITHOUT ARTIFICIAL INTELLIGENCE OR CHATGPT I don't understand why you use chatgpt, if I wanted to I would do it myself, I need to learn from you, not from being a d amn robot. SOLVE STEP BY STEP I WANT THE DIAGRAM PERFECTLY IN SIMULINKarrow_forwardI need to develop and run a program that prompts the user to enter a positive integer n, and then calculate the value of n factorial n! = multiplication of all integers between 1 and n, and print the value n! on the screen. This is for C*.arrow_forwardI need to develop and run a C* program to sum up integers from 1 to 100, and print out the sum value on the screen. Can someone help please?arrow_forward
- Given the schema below for the widgetshop, provide a schema diagram. Schema name Attributes Widget-schema Customer-schema (stocknum, manufacturer, description, weight, price, inventory) (custnum, name, address) Purchased-schema (custnum, stocknum, pdate) Requestedby-schema (stocknum, custnum) Newitem-schema (stocknum, manufacturer, description) Employee-schema (ssn, name, address, salary) You can remove the Newitem-schema (red).arrow_forwardTrue or False: Given the sets F and G with F being an element of G, is it always ture that P(F) is an element of P(G)? (P(F) and P(G) mean power sets). Why?arrow_forwardCan you please simplify (the domain is not empty) ∃xF (x) → ¬∃x(F (x) ∨ ¬G(x)). Foarrow_forward
- HistogramUse par(mfrow=c(2,2)) and output 4 plots with different argument settings.arrow_forward(use R language)Scatter plot(a). Run the R code example, and look at the help file for plot() function. Try different values for arguments:type, pch, lty, lwd, col(b). Use par(mfrow=c(3,2)) and output 6 plots with different argument settings.arrow_forward1. Draw flow charts for each of the following;a) A system that reads three numbers and prints the value of the largest number.b) A system reads an employee name (NAME), overtime hours worked (OVERTIME), hours absent(ABSENT) and determines the bonus payment (PAYMENT).arrow_forward
- Scenario You work for a small company that exports artisan chocolate. Although you measure your products in kilograms, you often get orders in both pounds and ounces. You have decided that rather than have to look up conversions all the time, you could use Python code to take inputs to make conversions between the different units of measurement. You will write three blocks of code. The first will convert kilograms to pounds and ounces. The second will convert pounds to kilograms and ounces. The third will convert ounces to kilograms and pounds. The conversions are as follows: 1 kilogram = 35.274 ounces 1 kilogram = 2.20462 pounds 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms 1 ounce = 0.0625 pounds For the purposes of this activity the template for a function has been provided. You have not yet covered functions in the course, but they are a way of reusing code. Like a Python script, a function can have zero or more parameters. In the code window you…arrow_forwardmake a screen capture showing the StegExpose resultsarrow_forwardWhich of the following is not one of the recommended criteria for strategic objectives? Multiple Choice a) realistic b) appropriate c) sustainable d) measurablearrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,