Write a java class votingmachinejava which allows one to


Assignment

MUST BE DONE ON BLUEJ

In this exercise you will create a simple VotingMachine. In the United States, when a candidate runs for office, the person is often identified as a Democrat, Republican, or Independent. Write a Java class (VotingMachine.java) which allows one to vote by party affiliation and will also allow us to query the number of votes for each party and who won the election. The behavior is given below:

VotingMachine vm = new VotingMachine();

vm.voteDemocrat();

vm.voteDemocrat();

vm.voteRepublican();

vm.voteIndependent();

vm.countDemocrat(); // returns 2

vm.countRepublican(); // returns 1

vm.countIndependent(); // returns 1

vm.whoWon(); // returns "Democrat"

For simplicity, you may assume that there will be no ties in this election.

Create a new project in BlueJ by clicking on the menu option Project > New project. This will create a folder with the project name (see below). All BlueJ project-related files for this project will be stored in this folder. Create new classes by clicking on the [New Class] button. All Java class files that you create (.java files) will be stored in the BlueJ project folder. The project folder will contain other files as well. After completing and testing your assignment, zip the entire BlueJ folder and submit it. Since your Instructor will need all files in the project folder, make sure you zip the entire folder. For this assignment the names of the BlueJ project, Java class files, and the zip file you submit are given below:

BlueJ project: voting_machine

Java files: VotingMachine.java

Submit the full zipped BlueJ project folder: voting_machine.zip

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a java class votingmachinejava which allows one to
Reference No:- TGS01723637

Now Priced at $40 (50% Discount)

Recommended (95%)

Rated (4.7/5)