Write a program that will record the votes for one of two candidates byusing the class VoteRecorder, which you will design and create. VoteRecorder will have static variables to keep track of the total votes forcandidates and instance variables to keep track of the votes made by a singleperson. It will have the following attributes:- nameCandidatePresident1—a static string that holds the name of thefirst candidate for president- nameCandidatePresident2—a static string that holds the name of thesecond candidate for president- nameCandidateVicePresident1—a static string that holds the name ofthe first candidate for vice president- nameCandidateVicePresident2—a static string that holds the name ofthe second candidate for vice president- votesCandidatePresident1—a static integer that holds the number ofvotes for the first candidate for president- votesCandidatePresident2—a static integer that holds the number ofvotes for the second candidate for president- votesCandidateVicePresident1—a static integer that holds the numberof votes for the first candidate for vice president- votesCandidateVicePresident2—a static integer that holds the numberof votes for the second candidate for vice president- myVoteForPresident—an integer that holds the vote of a single individualfor 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 singleindividual for vice president (0 for no choice, 1 for the first candidate,and 2 for the second candidate)In addition to appropriate constructors, VoteRecorder has the followingmethods:- setCandidatesPresident(String name1, String name2)— a staticmethod that sets the names of the two candidates for president- setCandidatesVicePresident(String name1, String name2)—astatic 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 withthe current total number of votes for both presidential candidates- getCurrentVoteVicePresident—a static method that returns a stringwith the current total number of votes for both vice presidential candidates- getAndConfirmVotes-a non static method that gets an individuals votes,confirms them, and then records them- getAVote(String name1, String name2)—a private method that returns a votechoice for a single race from an individual (0 for no choice, 1 for the firstcandidate, and 2 for the second candidate)- getVotes—a private method that returns a vote choice for president andvice president from an individual- confirmVotes- a private method that displays a persons vote for presidentand vice president, asks whether the voter is happy with these choices, andreturns true or false according to a yes-or-no response- recordVotes - a private method that will add an individuals votes to theappropriate static variables the appropriate static variablesCreate a program that will conduct an election. The candidates for presidentare 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 Recorder objectfor each voter. After all the voters are done, present theresults
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here