Write a java class which allows to vote by party affiliation

Assignment Help JAVA Programming
Reference no: EM131320984

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

Reference no: EM131320984

Questions Cloud

Targeting and growing the female market segment : Should under amour continue targeting and growing the female market segment? Or should it target a broader population to gain more traction on Nike and get closer to the number one spot?Should Under Armour keep paying famous athletes to be part of..
When do researchers use regression analysis : Distinguish among simultaneous (or standard), stepwise, and hierarchical regression.
Develop an action plan for creating your personal brand : Describe what you want your personal brand to be. In the next step, you develop an action plan for creating or enhancing your personal brand. Provide at least one clear example of an experience in this course that has helped, or may help, you move to..
What line is described by a regression equation : Write the general form of a regression equation that has a single predictor variable. Identify the criterion variable, the predictor variable, the regression constant, and the regression coefficient.
Write a java class which allows to vote by party affiliation : 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.
What is the after-tax holding-period return on the bond : A newly issued bond pays its coupons once annually. Its coupon rate is 5%, its maturity is 20 years, and its yield to maturity is 8%, and its face value is $1,000. Find the holding-period return for a 1-year investment period if the bond is selling a..
Write the pseudo code for the main program logic : When a user specifies a price, find any seat with that price and give feedback on the seat row and number and mark the seat as "SOLD". Repeat the process until the user exits the program. Write the pseudo code for the main program logic.
Which is worse--confound variance or error variance why : What are order effects, and how does counterbalancing help us deal with them?
Strategic decision partnering with the brotherhood : Did vineyard vines make a good strategic decision partnering with the brotherhood of the traveling plants?  How should vineyard vines proceed with its social media strategy?Was vineyard the right partnership for the brotherhood?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write program that takes theelevator-nxtthrough calibration

Write the program that takes theElevator-NXTthrough a calibration and test sequence, as shown in thisvideo. Raise the car as far as it goes to the top (the top floor).

  Prompts the user to enter 4 numbers for a salesperson

Write a program (SalespersonCommission.java) that prompts the user to enter 4 numbers for a salesperson's items sold for last week and displays that salesperson's earnings.

  Write a method that will perform the a division operation

Write a method that will perform the a division operation (divide by) on the numbers passed to it in two variables (numerator, denominator) and outputs the results. Use a try-catch pair to output an error message if the illegal operation of divide..

  Int variable with a boolean variable

In java programming Can we compare int variable with a boolean variable?

  A program with main() would produce output below

A  program with main() would produce output below - Your code ...Calling getLargestUncommonDigit()

  Develop the nonfunctional requirements design for the system

Some contractors and companies prefer to remain anonymous until they meet face-to face. Develop the nonfunctional requirements and architecture design for the system.

  Write a java program using classes and object

Use different program control statements in a programming language and demonstrate the use of arrays with a programming language and Define and work with classes and objects in a programming language.

  Write a recursive function that finds and returns the sum

Write a recursive function that finds and returns the sum of the elements of an int array. Also, write a program to test your function.

  Display a welcome message in a message dialog box

Display a welcome message in a Message Dialog Box (JOptionPane.showMessageDialog()) that includes the full name, e.g., "Welcome John Q Smith.".

  Create a book class for the library application project

Create a Book class for the Library application project. In addition to properties of author and isbn, with setters/getters, the Book should override Object's base method "boolean equals(Object)" and have a "boolean validate()" method.

  Create a two dimensional array

COSC 1436: Programming Fundamentals - Create a two dimensional array called snowfalltotal that will hold the values - Define meaningful variable names, but also have to give appropriate names for the physical java file, which should be the same as y..

  Create a program that will ask for gallon used

Create a program that will ask for both gallon used and mileage travelled; calculate the MPG. Create a program that ask for a radius of a circle and has the ability to return both the Area and Circumference.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd