-1
I have the following question:
2. Declare a vector of four positions of the whole data type, the software must remain asking the user to enter a value, until it enters four valid values, the valid values must be stored in the vector.
My progress so far is this:
try
{
int [] vetor = new int [4];
System.out.println("Informe o primeiro valor: ");
vetor[0]=teclado.nextInt();
System.out.println("Informe o segundo valor: ");
vetor[1]=teclado.nextInt();
System.out.println("Informe o terceiro valor: ");
vetor[2]=teclado.nextInt();
System.out.println("Informe o quarto valor: ");
vetor[3]=teclado.nextInt();
System.out.println("Foram digitados valores válidos.");
}catch(Exception erro)
{
System.out.println("Valor inválido.");
}
My question is: how to make it request the value until a valid value is entered.