Question: Write a java program using the following instructions: Write a program that determines election results. Create two parallel arrays to store the last names of

Write a java program using the following instructions:

Write a program that determines election results. Create two parallel arrays to store the last names of five candidates in a local election and the votes received by each candidate. Prompt the user to input these values. The program should output each candidates name, the votes received by that candidate, the percentage of the total votes received by the candidate, and the total votes cast. Your program should also output the winner of the election. To do this, write the following method: findHighest which receives an array of int. It determine the highest value in the array and returns the location of that value. Call this method to determine the location of the highest value in your votes array, and use this to display the winner from the names array.

SAMPLE OUTPUT:

Enter candidate name: Johnson

Enter votes received: 5000

Enter candidate name: Miller

Enter votes received: 4000

Enter candidate name: Duffy

Enter votes received: 6000

Enter candidate name: Robinson

Enter votes received: 2500

Enter candidate name: Ashton

Enter votes received: 1800

Candidate Votes Received % of Total

Johnson 5000 25.91

Miller 4000 20.72

Duffy 6000 31.09

Robinson 2500 12.95

Ashton 1800 9.33

Total votes: 19300

The winner of the election is Duffy.

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!