PROGRAMMING IN JAVA - ASSIGNMENT: JAVA CLASSES Instruction: Give java code for a support class called Vote
Fantastic news! We've Found the answer you've been seeking!
Question:
PROGRAMMING IN JAVA -
ASSIGNMENT: JAVA CLASSES
Instruction: Give java code for a support class called Vote that allows a user to add "yes" and "no" votes to some total votes, and allows the user to find out which has the higher number. Code class must contain the constructor and methods specified below!
Transcribed Image Text:
Give code for a support class called Vote that allows a user to add "yes" and "no" votes to some total votes, and allows the user to find out which has the higher number. More specifically, your class must contain the following constructor and methods: A constructor of the form Vote (int yesVotes, int noVotes) This constructor sets the initial number of "yes" votes to yesVotes and the initial number of "no" votes to of the point to novotes. public void yesVote() This method increments the number of "yes" votes by 1. ● public void noVote() This method increments the number of "no" votes by 1. public String getWinner () This method should return either "yes" or "no", depending on which has the higher total so far. For example: Vote v = new Vote (2, 1); v.yesVote(); Initially 2 "yes" votes and 1 "no" vote Now 3 "yes" votes v.novote (); Now 2 "no" votes System.out.println (v.getWinner ()); Prints "yes" Give code for a support class called Vote that allows a user to add "yes" and "no" votes to some total votes, and allows the user to find out which has the higher number. More specifically, your class must contain the following constructor and methods: A constructor of the form Vote (int yesVotes, int noVotes) This constructor sets the initial number of "yes" votes to yesVotes and the initial number of "no" votes to of the point to novotes. public void yesVote() This method increments the number of "yes" votes by 1. ● public void noVote() This method increments the number of "no" votes by 1. public String getWinner () This method should return either "yes" or "no", depending on which has the higher total so far. For example: Vote v = new Vote (2, 1); v.yesVote(); Initially 2 "yes" votes and 1 "no" vote Now 3 "yes" votes v.novote (); Now 2 "no" votes System.out.println (v.getWinner ()); Prints "yes"
Expert Answer:
Answer rating: 100% (QA)
Program based on the above question class Vote int yes0no0 public Voteint yesVotesint noVote... View the full answer
Related Book For
Posted Date:
Students also viewed these operating system questions
-
In this exercise, you code an application that allows the user to select one radio button from each of two groups: an English group and a Spanish group. Open the VB2015\ Chap05\Language...
-
Write a GUI application that allows the user to add new employees to the Personnel database you created in Programming Challenge 6. Data in Programming Challenge 6. Write an application that creates...
-
In this exercise, you create an application that allows the user to enter the gender (either F or M) and GPA for any number of students. The applications interface is shown in Figure 6-53. The...
-
Why are variances usually written off to cost of goods sold?
-
The Great North Woods Clothing Company is a mail-order company that processes thousands of mail and telephone orders each week. They have a customer service number to handle customer order problems,...
-
Regal Printing, Inc., prints and binds encyclopedias. The following information was found in the accounting records: Sales price per unit ....... $ 103 Direct materials per unit...... $ 50 Direct...
-
To make the dressing for coleslaw, Maddie needs to mix it with \(\frac{3}{5}\) mayonnaise and \(\frac{2}{5}\) apple cider vinegar. If Maddie wants to have 8 cups of dressing, how many cups of...
-
C.S. Lewis Company had the following transactions involving notes payable. July 1, 2014 Borrows $50,000 from First National Bank by signing a 9-month, 8% note. Nov. 1, 2014 Borrows $60,000 from Lyon...
-
This question topic is from Strategic Business Leader: Question: The Board of Bubble and Squeak , a medium sized soft toys manufacturing company, has recently decided to ask their internal audit...
-
The file P02_18.xlsx contains daily values of the Standard & Poors 500 Index from 1970 to early 2012. It also contains percentage changes in the index from each day to the next. a. Create a histogram...
-
As a buyer, you have been given a choice to buy intimate apparel, workout apparel, or swimwear. Choose one of these three areas and discuss fabric properties that would be needed to satisfy your...
-
In what ways do businesses adjust their accounts for accruals and prepayments?
-
Why is the profit made during an accounting period not necessarily equal to the cash flow during that period?
-
Computerised accounts and information systems have speeded up the recording of accounting data and the presentation of information. What are the other advantages over manual accounting systems and...
-
Managers who are non-accounting specialists dont need to learn about bookkeeping, debits and credits, etc. Discuss.
-
Which of the following distinguishes an informal group from a formal group? a. An informal group consists of members who did not formerly know each other. b. An informal group is organised by top...
-
Aristotle has said that three elements in an effective persuasive argument are: ethos (credibility), pathos (emotional appeal), and logos (logical appeal). If you are able to include these three...
-
a) Calculate the goodwill that was paid by Major Ltd on the acquisition of Minor Ltd. [10 marks] b) Prepare the consolidated statement of financial position for Major Ltd at 31 July 20X8. [30 marks]...
-
The chi-squared mgf with df = is m(t) = (12t) /2 , for |t| < . Use it to prove the reproductive property of the chi-squared distribution.
-
Refer to the independence model, ij = i j . For the corresponding loglinear model (8.1): a. Show that one can constrain i X = j Y = 0 by setting b. Show that one can constrain 1 X = 1 Y = 0 by...
-
One question in the 1990 General Social Survey asked subjects how many times they had sexual intercourse in the preceding month. Table 13.9 shows responses, classified by gender. a. The sample means...
-
In SAS No. 82, what are some industry condition risk factors? Some operating and financial stability risk characteristics?
-
What superseded SAS No. 82?
-
What is PCAOB's definition of internal controls?
Study smarter with the SolutionInn App