Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class VotingMachine // - ---Start below here. To do: approximate lines of code = 23 11 * Create 4 instance variables. Two are of

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

public class VotingMachine // - ---Start below here. To do: approximate lines of code = 23 11 * Create 4 instance variables. Two are of type String and * each stores the name of a political party * Two are of type int and they store the number of votes for * each political party Create a constructor method that has 2 String arguments which are used to initialize the name of each political party Set the number of votes for each party to /** Create a public method voteParty1() which adds one vote for political party 1 Create a public method voteParty2() which adds one vote for political party 2 * Create a public method newElection) that sets the current number of votes for * each political party to * Create a public method getWinner() that returns a String. * If party 1 has more votes than party 2 then return the string * containing: the name of party i followed by " win the election with * followed by the number of votes for party 1 followed by "votes" If party 2 has more votes than party 1 then return the string * containing: the name of party 2 followed by " win the election with followed by the number of votes for party 2 followed by "votes" If party 2 has the same votes as party 1 then return the string containing: the name of party 1 followed by " and "followed by the name of party 2 followed by " tied with " followed by the number of votes for party 1 import java.util. Random; public class VotingMachineTester public static void main(String[] args) VotingMachine vm = new VotingMachine("Democrats", "Republicans"); int votes1 = 7736; for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago