1. Write a program that will input 5 numbers and will determine if the input numbers are odd and even, then compute and display the sum of all even and odd numbers. Use while / do while / for loop.

PHOTO EMBED

Sun Dec 08 2024 11:34:01 GMT+0000 (Coordinated Universal Time)

Saved by @John_Almer

        Scanner input = new Scanner(System.in);
        int positiveCount = 0, negativeCount = 0;

        for (int i = 1; i <= 5; i++) {
            System.out.print("Enter number " + i + ": ");
            int num = input.nextInt();

            if (num > 0) {
                positiveCount++;
            } else if (num < 0) {
                negativeCount++;
            }
        }

        System.out.println("Positive: " + positiveCount);
        System.out.println("Negative: " + negativeCount);
    }
}
content_copyCOPY