Computer Science, asked by arjunSrinivas, 17 hours ago

Take 12 integer inputs from user and then count how many positive and how many even and how many odd numbers are there in the array.

Answers

Answered by samarthkrv
7

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 int[] numbers = new int[12];

 int even = 0 , odd = 0;

 Scanner sc = new Scanner(System.in);

 System.out.println("Enter all 12 numbers:");

     for(int i = 0; i < numbers.length; i++){

         numbers[i] = sc.nextInt();

             if(numbers[i]%2 == 0){

                 even++;

             }

             else{

                 odd++;

             }

     }

    System.out.println("---THE 12 NUMBERS YOU ENTERED---");

        for(int i = 0; i < numbers.length; i++){

            System.out.print(numbers[i] + " ");

        }

        System.out.println("\nThe number of even numbers in the array: " + even);

        System.out.println("The number of odd numbers in the array: " + odd);

}

}

Explanation:

Similar questions