package esercitazione1; import java.util.Scanner; public class Esercizio2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Quanti numeri vuoi sommare?"); int n = in.nextInt(); int x; int res = 0; while (n > 0) { System.out.println("Inserisci il prossimo numero da sommare:"); x = in.nextInt(); res += x; n--; } System.out.println("Risultato: " + res); } }