Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class p2 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int cantidad;
- int pares = 0;
- int impar = 0;
- int positivo = 0;
- int negativo = 0;
- int contador = 1;
- int numeroIngresado;
- System.out.print("Ingrese la cantidad de digitos: ");
- cantidad = sc.nextInt();
- while (contador <= cantidad){
- System.out.print("Digite el numero " + contador + " : ");
- numeroIngresado = sc.nextInt();
- if (numeroIngresado % 2 == 0){
- pares ++;
- }else{
- impar ++;
- }
- if (numeroIngresado > 0){
- positivo ++;
- }
- else{
- negativo ++;
- }
- contador ++;
- }
- System.out.println("Pares: " + pares);
- System.out.println("Impares: " + impar);
- System.out.println("Positivos: " + positivo);
- System.out.println("Negativos: " + negativo);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement