Struttura iniziale
This commit is contained in:
parent
c326b1ec2f
commit
d9731037f2
@ -20,53 +20,23 @@ public class SequenzaNumeri {
|
|||||||
static Scanner sc = new Scanner(System.in);
|
static Scanner sc = new Scanner(System.in);
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
int scelta = -1;
|
int daLeggere = -1;
|
||||||
|
boolean error;
|
||||||
|
|
||||||
|
System.out.println("Verrà chiesto di inserire la quantità di numeri da inserire.");
|
||||||
|
Pausa();
|
||||||
|
|
||||||
do{
|
do{
|
||||||
System.out.println("Scegliere un'opzione:");
|
error = false;
|
||||||
System.out.println("1. Stampa quadrato pieno");
|
daLeggere = InserimentoNumero();
|
||||||
System.out.println("2. Stampa quadrato vuoto");
|
|
||||||
System.out.println("3. Stampa triangolo");
|
|
||||||
System.out.println("4. Stampa quadrato diagonale");
|
|
||||||
System.out.println("0. Esci");
|
|
||||||
System.out.println("Scelta: ");
|
|
||||||
|
|
||||||
try {
|
if(daLeggere <= 0){
|
||||||
scelta = sc.nextInt();
|
System.out.println("Errore: inserire un numero positivo.");
|
||||||
sc.nextLine();
|
|
||||||
|
|
||||||
switch (scelta) {
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
System.out.println(QuadratoPieno(Dimensione(), unit));
|
|
||||||
Pausa();
|
Pausa();
|
||||||
break;
|
error = true;
|
||||||
case 2:
|
|
||||||
System.out.println(QuadratoVuoto(Dimensione(), unit));
|
|
||||||
Pausa();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
System.out.println(Triangolo(Dimensione(), unit));
|
|
||||||
Pausa();
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
System.out.println(QuadratoDiagonale(Dimensione(), unit, unit2));
|
|
||||||
Pausa();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
System.out.println("Errore: scelta non valida.");
|
|
||||||
Pausa();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (InputMismatchException e) {
|
while (error);
|
||||||
System.out.println("Errore: scelta non valida.");
|
|
||||||
Pausa();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
while (scelta != 0);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -78,9 +48,10 @@ public class SequenzaNumeri {
|
|||||||
|
|
||||||
static int InserimentoNumero() {
|
static int InserimentoNumero() {
|
||||||
int ritorno = 0;
|
int ritorno = 0;
|
||||||
boolean error = false;
|
boolean error;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
error = false;
|
||||||
System.out.println("Inserire un numero: ");
|
System.out.println("Inserire un numero: ");
|
||||||
try{
|
try{
|
||||||
ritorno = sc.nextInt();
|
ritorno = sc.nextInt();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user