Está en la página 1de 2

// Programa que ingrese un tope (validar el tope) y contar cuantos numeros son positivos y cuantos son negativos.

import java.util.Scanner; public class Deber2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner obj=new Scanner(System.in); int tope=obj.nextInt(); do { System.out.println("Ingrese un tope mayor de cero"); tope=obj.nextInt(); } while(tope <= 0);// || (obj.nextInt()==obj.nextFloat())); System.out.println("El tope de numeros que se va a ingresar son: "+tope); int cont=0,cont1=0; for(int i=0;i<tope;i++) { System.out.println("Ingrese un numero: "); int n=obj.nextInt(); if(n<0) { cont=cont+1; } else { cont1=cont1+1; } System.out.println("Los numeros positivos son: +cont1+ "\nLos numeros negativos son: "+cont); } System.out.println("Realizado por: Daniel Guevara"); } } "

También podría gustarte