import java.util.Scanner;
public class Highest{
public static void main (String [] args){

Scanner kb = new Scanner(System.in);

int scores [] = new int[3];
String names [] = new String [3];
int highest = scores [0];
String names1 = names [0];

for (int i = 0; i<3; i++){
   System.out.println("enter name and score: ");
   names[i] = kb.next();
   scores[i] = kb.nextInt();
      if (scores[i] > highest)
         highest = scores[i];
         names1 = names[i];

}



System.out.println(highest + names1);


}
}

i'm stuck on the part where i have to extract the name that associates with the highest score. it always prints out the last name that i enter instead of the one with the highest score.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.