Question: Book:- Java An introdcution to problem solving and programming 7ed plz give the write code in Java Chapter 6 : Programming Projects 10: This project

Book:- Java An introdcution to problem solving and programming 7ed

plz give the write code in Java

Chapter 6:

Programming Projects 10: This project is found starting on page 480

Assignment guidelines:

Write a program that will record the votes for one of two candidates by using the class VoteRecorder, which you will design and create.VoteRecorder 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:

nameCandidatePresident1a static string that holds the name of the first candidate for president

nameCandidatePresident2a static string that holds the name of the second candidate for president

nameCandidateVicePresident1a static string that holds the name of the first candidate for vice president

nameCandidateVicePresident2a static string that holds the name of the second candidate for vice president

votesCandidatePresident1a static integer that holds the number of votes for the first candidate for president

votesCandidatePresident2a static integer that holds the number of votes for the second candidate for president

votesCandidateVicePresident1a static integer that holds the number of votes for the first candidate for vice president

votesCandidateVicePresident2a static integer that holds the number of votes for the second candidate for vice president

myVoteForPresidentan 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)

myVoteForVicePresidentan 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, VoteRecorder has the following methods:

setCandidatesPresident(String name1, String name2)a static method that sets the names of the two candidates for president

setCandidatesVicePresident(String name1, String name2)a static method that sets the names of the two candidates for vice president

resetVotesa static method that resets the vote counts to zero

getCurrentVotePresidenta static method that returns a string with the current total number of votes for both presidential candidates

getCurrentVoteVicePresidenta static method that returns a string with the current total number of votes for both vice presidential candidates

getAndConfirmVotesa nonstatic method that gets an individuals votes, confirms them, and then records them.

getAVote(String name1, String name2)a private method that returns a vote choice for a single race from an individual (0 for no choice, 1 for the first candidate, and 2 for the second candidate)

getVotesa private method that returns a vote choice for president and vice president from an individual

confirmVotesa private method that displays a persons 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

recordVotesa private method that will add an individuals votes to the appropriate static variables object for each voter.

After all the voters are done, present the resultsVoteRecorder. Create a class, VoteRecorderDemo, that will conduct 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 as many voters are available, no fixed or specific number. For voting, create a new VoteRecorder object for each voter. After all the voters are done, present the results.

Note:

The assignment must have the following files:

1. class voteRecorder, in file voteRecorder.java

2. class voteRecorderDemo, in a file voteRecorderDemo.java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!