/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
 */
package autosuma;

import java.util.Scanner;

/**
 *
 * @author Blasco
 */
public class Autosuma {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("¿Cuántos números vas a meter? ");
        int limite = sc.nextInt();
        sc.nextLine();
        int[] numeros = new int[limite];
        int numero;
        int suma = 0;
        for (int i = 0; i < limite; i++) {
            System.out.print("Introduce un número: ");
            numero = sc.nextInt();
            sc.nextLine();
            numeros[i] = numero;
        }
        System.out.print("\nNúmeros [");
        for (int i = 0; i < numeros.length; i++) {
            if(i == numeros.length){
                System.out.print(numeros[i]);
            } else {
                System.out.print(numeros[i] + ", ");
            }
        }
        System.out.print("]\n\n");
        for (int i = 0; i < numeros.length; i++) {
            suma += numeros[i];
        }
        System.out.println("SUMA: " + suma);
        sc.close();
    }
    
}
