Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OddOrEven {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter how many numbers: ");
- int n = sc.nextInt();
- int odd = 0;
- int even = 0;
- for (int i = 1; i <= n; i++) {
- System.out.print("Enter number " + i + ": ");
- int x = sc.nextInt();
- if (x % 2 == 0) {
- even++;
- } else {
- odd++;
- }
- }
- System.out.println("Odd count: " + odd);
- System.out.println("Even count: " + even);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement