SlideShare a Scribd company logo
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package suma.de.n.numeroscon.pkgfor.stram;

import java.io.*;
/**
 *
 * @author FEDORA HUMBERTO CALLEJA JUAREZ
 */
public class SumaDeNNumerosconForStram {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)throws IOException {
        // TODO code application logic here
        InputStreamReader abc = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader (abc);
        try
        {
            int suma=0;
            int num =0 ;
            System.out.print("ingrese la cantidad de datos :");
            double can = Integer.parseInt(reader.readLine());
            for(int i=1;i<=can;i++)
            {

                System.out.print("numero: ");
                num += Integer.parseInt(reader.readLine());
                suma=num;
            }
            System.err.println("la suma es: "+suma);
        }
        catch (IOException | NumberFormatException e)
        {
            System.err.println("verifique el dato");
        }
    }
}

More Related Content

What's hot

Effective java 摘選條目分享 2 - 泛型
Effective java   摘選條目分享 2 - 泛型Effective java   摘選條目分享 2 - 泛型
Effective java 摘選條目分享 2 - 泛型
Kane Shih
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3
Platonov Sergey
 
Tmpj2 01 201181102muhammad tohir
Tmpj2 01 201181102muhammad tohirTmpj2 01 201181102muhammad tohir
Tmpj2 01 201181102muhammad tohirpencari buku
 
Ejercicios
EjerciciosEjercicios
Ejercicios
Jhair Aguirre
 
Tugas kelompok 3.5
Tugas kelompok 3.5Tugas kelompok 3.5
Tugas kelompok 3.5
1300018075
 
Linked list proj
Linked list projLinked list proj
Linked list proj
Dr. Ahmed J. Obaid
 
Создание новых объектов
Создание новых объектовСоздание новых объектов
Создание новых объектов
Constantin Kichinsky
 
Dij
DijDij
Soalan tmk tahun 4 peperiksaan pertengahan tahun
Soalan tmk tahun 4 peperiksaan pertengahan tahunSoalan tmk tahun 4 peperiksaan pertengahan tahun
Soalan tmk tahun 4 peperiksaan pertengahan tahun
Botol Budu
 
08 1 함수란
08 1 함수란08 1 함수란
Java лаб13
Java лаб13Java лаб13
Java лаб13Enkhee99
 
Colecções C#
Colecções C#Colecções C#
Colecções C#nonametgp1
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
Eleanor McHugh
 
Serie de fibbonacci recursivo en java
Serie de fibbonacci recursivo en javaSerie de fibbonacci recursivo en java
Serie de fibbonacci recursivo en java
jbersosa
 

What's hot (19)

Osmose
OsmoseOsmose
Osmose
 
Effective java 摘選條目分享 2 - 泛型
Effective java   摘選條目分享 2 - 泛型Effective java   摘選條目分享 2 - 泛型
Effective java 摘選條目分享 2 - 泛型
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3
 
Tmpj2 01 201181102muhammad tohir
Tmpj2 01 201181102muhammad tohirTmpj2 01 201181102muhammad tohir
Tmpj2 01 201181102muhammad tohir
 
Java
Java Java
Java
 
Ejercicios
EjerciciosEjercicios
Ejercicios
 
Tugas kelompok 3.5
Tugas kelompok 3.5Tugas kelompok 3.5
Tugas kelompok 3.5
 
Linked list proj
Linked list projLinked list proj
Linked list proj
 
Создание новых объектов
Создание новых объектовСоздание новых объектов
Создание новых объектов
 
Dij
DijDij
Dij
 
Jslunch1
Jslunch1Jslunch1
Jslunch1
 
Soalan tmk tahun 4 peperiksaan pertengahan tahun
Soalan tmk tahun 4 peperiksaan pertengahan tahunSoalan tmk tahun 4 peperiksaan pertengahan tahun
Soalan tmk tahun 4 peperiksaan pertengahan tahun
 
Lector
LectorLector
Lector
 
08 1 함수란
08 1 함수란08 1 함수란
08 1 함수란
 
Java лаб13
Java лаб13Java лаб13
Java лаб13
 
Cajero
CajeroCajero
Cajero
 
Colecções C#
Colecções C#Colecções C#
Colecções C#
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
 
Serie de fibbonacci recursivo en java
Serie de fibbonacci recursivo en javaSerie de fibbonacci recursivo en java
Serie de fibbonacci recursivo en java
 

Suma de n numeros en java

  • 1. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package suma.de.n.numeroscon.pkgfor.stram; import java.io.*; /** * * @author FEDORA HUMBERTO CALLEJA JUAREZ */ public class SumaDeNNumerosconForStram { /** * @param args the command line arguments */ public static void main(String[] args)throws IOException { // TODO code application logic here InputStreamReader abc = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader (abc); try { int suma=0; int num =0 ; System.out.print("ingrese la cantidad de datos :"); double can = Integer.parseInt(reader.readLine()); for(int i=1;i<=can;i++) { System.out.print("numero: "); num += Integer.parseInt(reader.readLine()); suma=num; } System.err.println("la suma es: "+suma); } catch (IOException | NumberFormatException e) { System.err.println("verifique el dato"); } } }