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:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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:

- nameCandidatePresident1—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
- votesCandidatePresident1—a static integer that holds the number of
votes for the first candidate for president
- votesCandidatePresident2—a static integer that holds the number of
votes 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 votes 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, 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
- resetVotes—a static method that resets the vote counts to zero
- getCurrentVotePresident—a static method that returns a string with
the current total number of votes for both presidential candidates
- getCurrentVoteVicePresident—a static method that returns a string
with 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 vote
choice for a single race from an 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 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
- recordVotes - a private method that will add an individuals votes to the
appropriate static variables the appropriate static variables

Create a program 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 many voters. Create a new Recorder object
for each voter. After all the voters are done, present the
results

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education