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?
-
iLife, Inc., was set to report the following statement of retained earnings for the year ended December 31, 2014: iLife, Inc. Statement of Retained Earnings Year Ended December 31, 2014 Retained...
-
Cost-Volume-Profit Analysis and Return on Investment (ROl) posters.com is a small Internet retailer of high-quality posters. The company has $1,000,000 in operating assets and fixed expenses of...
-
The case study that involved balancing a gas turbine that could not pass through its first critical frequency called for use of the existing proximity probe outputs input into a digital FFT using...
-
Multiply Choice 1. Sequential access means that a. Data are stored on magnetic tape. b. The address of the location of data is found through the use of either an algorithm or an index. c. To read any...
-
You are a Morgan Stanley portfolio manager of a risky portfolio with an expected rate of return of 19% and a standard deviation of 28%. The T-bill rate is 7%. Suppose your client decides to invest in...
-
bring this packet with you to every class as this is an ongoing problem. Chart of Accounts 11. Cash 31. Jolene Upton, Capital 12. Accounts receivable 14. Supplies 15. Prepaid rent 16 Prepaid...
-
Given an LTI digital filter with the following I/O equation, answer the following questions: y(n) = 0.3x(n) + 0.5x(n-1) + 0.3x(n-2) (1) What's the filter's impulse response? (2) Is the filter...
-
196. By which process man has obtained many breeds of plants and animals for agriculture, horticulture, food and security? (1) Natural selection (2) Random breeding (3) Artificial selection (4) Both...
-
An m = 0.5 kg compresses a spring of force constant 500 N/m a distance 0.2 m from its natural length. When the block is released, it travels up a rough incline that is h = 0.4 m high and 2 m long....
-
Calculate the investment and operation cost of all three alternatives according to the following loading profile over the first 10 years. Assume that energy costs 30 Eur / MWh and the total running...
-
A 20-Kilogram car traveling east at 6 meters per second collides with a 30-Kilogram car that is traveling west. If both the cars come to rest immediately after the collision, what was the speed of...
-
Sales (33,000 units @ $16) Sales discounts Purchases Purchase discounts Freight-in Freight-out $ 528,000 7,500 380,600 18,000 5,000 11,000 York Company's inventory purchases during 2024 were as...
-
A 2001b dresser is being pushed across the floor with force F. If the force being applied is F = 50 lbs and the coeff. Of friction is k = 0.2, find the acceleration of the dresser.
-
Explain the buyers position in a typical negotiation for a business. Explain the sellers position. What tips would you offer a buyer about to begin negotiating the purchase of a business?
-
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 the previous example, suppose that these are all of the entries in Freedonias BOP table. Calculate the value of errors and omissions. TABLE 11.2 Balance-of-Payments Example Merchandise exports...
-
Consider the demand and supply curves in Exercise 13. DATA FROM EXERCISE13 Suppose that the domestic demand and supply for shoes in a small open economy are given by. where P denotes price and Q...
-
Repeat Exercise 6 under the assumption that instead of a fall in demand for foreign exchange, there is an increase in supply. data from exercise 6 Credit entries in a countrys balance of payments...
Study smarter with the SolutionInn App