Download - Practica 2

Transcript
Page 1: Practica 2

UNIVERSIDAD NACIONAL DE CHIMBORAZO

FACULTAD DE CIENCIAS DE LA EDUCACION HUMANAS Y TECNOLOGIAS

NOMBRE: ANA CECILIA SAULA

PRACTICA 2

EJERCICIO 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

/ /ANA CECILIA SAULA//

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);

}

}

Page 2: Practica 2

EJECUCIÓN