Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Program need help... Prompt: The elections are complicated on planet Galax.

ID: 3793662 • Letter: J

Question

Java Program need help...

Prompt: The elections are complicated on planet Galax. The winner isnt the person with the most votes, but the one whose vote total is divisible by both 3 and 8. The math always works out such that just one candidate satisfies both conditions, or else no one does, in which case a candidate is randomly chosen. Unfortunately the Galaxers dont know how to determine this. Once again, you come to the rescue with the following method:

public static String getWinner (int [ ] results, String [ ] names) { }

can you fill out the rest of the code?



Explanation / Answer

public static String getWinner (int [ ] results, String [ ] names)
{
int count = names.length();
String winner = "";

for(int i=0;i<count;i++)
{
   if( results[i]% 3 == 0)
   {
  if( results[i]% 8 == 0)
  {
           winner = names[i];
           return winner;    
  }
   
   }
}


return "No one is winner";
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote