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 figure illustrates a stepped torsion-bar spring OA with an actuating cantilever AB. Both parts are of carbon steel. Use superposition and find the spring rate k corresponding to a force F acting...
-
Cassandra SA's comparative statements of financial position are presented below. Additional information: 1. Net income was ¬23,300. Dividends declared and paid were ¬14,600. 2. Equipment that...
-
Refer to Exercise 12. Assume you did not know that the two samples were paired, so you used the methods of Section 11.1 to perform the test. a. What is the P-value? b. Explain why the P-value is...
-
Revenue recognition at and after time of sale. Assume that during December 2008, Nordstrom sold $20 million of merchandise and another $12 million of gift cards, of which $24 million was on credit...
-
As an average investor, should you actively trade stocks in a semi-strong form efficient market? Why or why not
-
ATV Co. began operations on March 1 and uses a perpetual inventory system. It entered into purchases and sales for March as shown in the Tableau Dashboard. Legend No Purchases or Sales Purchases...
-
Ronald owns a property in Repulse Bay which was let under the following terms: (1) Term: 1 January 2018 to 31 December 2020. (2) Rental deposit: S80,000. (3) Monthly Rent: S30,000. (4) Rates: $3,000...
-
What Laissez faire leadership most likely represents ?
-
Laundry soap is comprised of molecules such as RCOONa, where R represents an alkyl chain. For example: Q2. What is the molecular formula of this species? What pH was obtained for the laundry soap...
-
When a corporation distributes some of its earnings to its owners/stockholders, what is the distribution called? Discuss.
-
Suppose that in April 2019, Nike Inc. had EPS of $2.69 and a book value of equity of $5.71 per share. a. Using the average P/E multiple from the table here, estimate Nike's share price. PE PriceBook...
-
A deposit of RM 1 , 5 0 0 is made into a fund on March 1 8 . The fund earns simple interest at 5 % . On August 5 , the interest rate changes to 4 . 5 % . How much is in the fund on October 2 3 ?
-
Social Media, Inc. (SMI) has two services for users. Toot!, which connects t with students who are looking for tutoring services, and TiX, which can be used to buy, sell, or exchange event tickets....
-
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...
-
a. Who may bring suit under the 1934 Securities Exchange Act? b. Is the basis for action the same as in a 1933 Act suit? Explain.
-
What are the responsibilities of the plaintiff and the defendant in a 1933 Act suit?
-
Under what circumstances will a statement be presumed to be misleading?
Study smarter with the SolutionInn App