Question: Java We are going to write a program that will help a talent show keep track of the votes the participants receive and determine who
Java
We are going to write a program that will help a talent show keep track of the votes the participants receive and determine who the winner is. For this program you will need to use: arrays, loops, selection statements, and write some methods. You will store the names of the contestants an array of Strings. You can either use the same names as in my example below, or you can use your own names. You need to have at least 10 contestants. You also need an array of integers of the same size as the array of Strings. You will use this array to keep track of how many votes each contestant receives. The program starts by displaying a table with the names of the contestants and a numeric code for each contestant.
The program should then let the user enter votes, one at the time, for the participants. This is done by asking the user to enter the numeric code of the participant receiving a vote. You will use a loop so the user can enter as many votes as he/she needs.
Validation: your program should validate the codes enter by the user. If there are 10 contestants, valid codes will be integer values between 1 and 10. Other values should be rejected and the user should be prompted to enter a valid code.
Once all the votes have been entered, the program should print a table with the names of the contestants and the total number of vote each one received. The program must also print the name of the winner.
Your program must include at least the following methods, in addition to the main() method:
A method that displays a table with the contestants names and their codes.
A method that figures out and return the name of the winner.
A method that displays a table with the contestants names and the votes each of them received.
You are free to write other methods in your program as you see fit.
Warning: you are not allowed to use global variables or the continue/break statements in your loops. Values from main() needed by a method should be passed as parameters. Loops should be written with proper terminating conditions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
