Question: coding java help please urgent Problem #2: (20 pts] _Voting Program Two candidates are running for president of a service organization. The winner is the

coding java help please urgent

coding java help please urgent Problem #2: (20 pts] _Voting Program Two

Problem #2: (20 pts] _Voting Program Two candidates are running for president of a service organization. The winner is the candidate with the most votes. Write a Java program that asks the user to enter the number of voters in the organization and the number of votes for each candidate. Your program displays which candidate wins and if he/she wins by majority. If one candidate has more than 50% of the votes, then he/she wins by majority. NB: If any of the integers is negative, then the program displays the message Invalid number(s)! In case of draw, the message "It is a draw, select a candidate at random is displayed. Sample run 1: Enter the number of voters: 40 Enter number of votes for candidate 1: 15 Enter number of votes for candidate 2: 12 Candidate 1 wins. He/she didn't win by majority, because the percentage is 37.5% Hint: Candidate 1 didn't win by majority because only 15 voters out of 40 voted in his favor. Sample run 2: Enter the number of voters: 40 Enter number of votes for candidate 1: -15 Enter number of votes for candidate 2: 12 Invalid number(s)! Sample run 3: Enter the number of voters: 20 Enter number of votes for candidate 1: 10 Enter number of votes for candidate 2: 11 Candidate 2 wins. He/she wins by majority, because the percentage is 55.0% Hint: Candidate 2 wins by majority because 11 voters out of 20 voted in his favor. Sample run 4: Enter the number of voters: 20 Enter number of votes for candidate 1: 10 Enter number of votes for candidate 2: 10 It is a draw, select a candidate at random

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!