Advertisement
JoshJurban

Exercise 6.2B

Oct 23rd, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. package chapterSix;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class IntegerReaders
  6. {
  7.     public static void main(String[] args)
  8.     {
  9.     Scanner s = new Scanner (System.in);
  10.     System.out.println("Inputs:");
  11.    
  12.     int evens = 0;
  13.     int odds = 0;
  14.  
  15.     while(s.hasNextInt())
  16.     {
  17.         int input = s.nextInt();
  18.         if (input % 2 == 0)
  19.         {
  20.             evens++;
  21.         }
  22.         else
  23.         {
  24.             odds++;
  25.         }
  26.     }
  27.     System.out.println("Number of odds:" + odds);
  28.     System.out.println("Number of evens"+ evens);
  29.     }
  30.    
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement