Question: 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

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!