Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Finish the program in java to determine the winner of the Caldwell City Mayoral Race. public class ihill 2 { public static void main (

Finish the program in java to determine the winner of the Caldwell City Mayoral Race. public class ihill2
{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
String[] candidates = new String[4];
int[] precinctOne = new int[4];
int[] precinctTwo = new int[4];
int[] precinctThree = new int[4];
int totalVotes =0;
int winnerCandidate = precinctOne[0]+precinctTwo[0]+precinctThree[0];
//input the canidates name and total votes
for (int i=0; i<4; i++){
System.out.println("Enter the name of the candidate:");
candidates[i]= scanner.nextLine();
System.out.println("Enter how many votes in Precinct 1 for "+ candidates[i]+": ");
precinctOne[i]= scanner.nextInt();
scanner.nextLine();
System.out.println("Enter how many votes in Precinct 2 for "+ candidates[i]+": ");
precinctTwo[i]= scanner.nextInt();
scanner.nextLine();
System.out.println("Enter how many votes in Precinct 3 for "+ candidates[i]+": ");
precinctThree[i]= scanner.nextInt();
scanner.nextLine();
}
//display the total of votes
totalVotes = precinctOne[0]+precinctTwo[0]+precinctThree[0];
System.out.println("Total Votes: "+ totalVotes);

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago