I'm trying to figure out how to read multiple entries from the Scanner class in Java. I need to get the name of each person entered and then compare the total amounts to each entry.
Here is my code:
String[] salespersons = new String[3];
System.out.println("Please enter at least two salespeople but no more than four, to compare sales against: ");
// use scanner class to read input from the user
Scanner input = new Scanner(System.in);
String line = input.nextLine();
String[] values = line.split(",");
for (String s: values) {
salespersons = values;
}
For some reasons, I can't get the values that are placed in salespersons. (I am really new to Java, sorry if my question does not make a lot of sense).