/** * Programma che prende in input un voto e stampa un giudizio tra * Ottimo, Buono, Sufficiente e Insufficiente. L'indentazione classica * con gli if annidati rende il programma difficile da leggere. */ import java.util.Scanner; public class P2Voto2 { public static void main(String[] args) { System.out.print("Immetti voto in trentesimi (tra 0 e 30): "); Scanner tastiera = new Scanner(System.in); int voto = tastiera.nextInt(); if (voto >= 27 && voto <= 30) { System.out.println("Ottimo"); } else { if (voto >= 21 && voto <= 26) { System.out.println("Buono"); } else { if (voto >= 18 && voto <= 20) { System.out.println("Sufficiente"); } else { System.out.println("Insufficiente"); } } } tastiera.close(); } }