0
I did a search by google but could not get an answer that illuminated my head, I’m starting to study java and I came across the following problem:
Create a Java program that reads from the keyboard 10 names and their salaries and then show the name of who has the highest and lowest salary.
Remembering that I still haven’t done the if part at the end to compare, my own doubt is how to save different variables using the scanner.
From now on Obriagdo:
public static void main(String[] args) {
String nome1;
int salario1;
int contador = 0;
while (contador <= 15) {
System.out.println(" Qual o seu nome?");
Scanner nome = new Scanner(System.in);
nome1 = nome.next();
System.out.println(" Qual o seu salário?");
Scanner salario = new Scanner(System.in);
salario1 = salario.nextInt();
contador = (contador + 1);
}
}
Recommended reading https://answall.com/questions/209571/erro-nosuchelementexception-ao-capturr-dataentrada-com-scanner/209580#209580
– user28595