Practica 2

Post on 26-Jul-2015

25 views 1 download

Transcript of Practica 2

UNIVERSIDAD NACIONAL DE CHIMBORAZO

FACULTAD DE CIENCIAS DE LA EDUCACION HUMANAS Y TECNOLOGIAS

NOMBRE: CESAR YUPA

PRACTICA 2EJERCICIO 1

Ingrese N números y muestre cuántos números mayores que cero han sido por el usuario, así como la suma de todos

DESARROLLO

/ CESAR YUPA//import java.util.Scanner;class numeros {

public static void main (String arg[]){Scanner datos=new Scanner(System.in);double i,r,n,suma,v;System.out.println("****SUMAR NUMEROS MAYOR A 0 Y CONTARLOS*****");System.out.println("******ingrese el numero total de elementos*******");v=datos.nextDouble();r=0;suma=0;

for(i=1;i<=v;i++){

System.out.println("****ingrese un numero*****");n=datos.nextDouble();suma=suma+n;if(n>0){r=r+1;

}}System.out.println("los numeros mayores a cero son :"+r);System.out.println("la suma de todos los numeros es:"+suma);

}}

EJECUCIÓN