EvenOdd.java - import java.util.Scanner public class EvenOdd public static void main(String args Scanner scnr = new Scanner(System.in boolean p = true

EvenOdd.java - import java.util.Scanner public class...

This preview shows page 1 out of 1 page.

import java.util.Scanner; public class EvenOdd { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); boolean p = true; int even = 0; int odd = 0; String a; while (p) { if (scnr.hasNextInt()) { a = scnr.nextLine(); int c = Integer.parseInt(a); if (c % 2 == 0) { ++even; } else { ++odd; } } else { p = false; } } if (even > odd) { System.out.println("E"); } else if (odd > even) { System.out.println("O"); } else { System.out.println("="); } } }

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture