InserimentoNumero
This commit is contained in:
parent
c2102b709d
commit
c326b1ec2f
@ -4,6 +4,7 @@
|
||||
*/
|
||||
package sequenzanumeri;
|
||||
|
||||
import java.util.InputMismatchException;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
@ -74,4 +75,23 @@ public class SequenzaNumeri {
|
||||
System.out.println("Premere un tasto per continuare. . .");
|
||||
sc.nextLine();
|
||||
}
|
||||
|
||||
static int InserimentoNumero() {
|
||||
int ritorno = 0;
|
||||
boolean error = false;
|
||||
|
||||
do{
|
||||
System.out.println("Inserire un numero: ");
|
||||
try{
|
||||
ritorno = sc.nextInt();
|
||||
}
|
||||
catch (InputMismatchException e) {
|
||||
System.out.println("Numero non valido.");
|
||||
Pausa();
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
while (error);
|
||||
return ritorno;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user