Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

How do books become world of wonder?

Answered: 1 week ago

Question

If ( A^2 - A + I = 0 ), then inverse of matrix ( A ) is?

Answered: 1 week ago