micher43

E6.2 part B

Oct 23rd, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class E62 {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner s = new Scanner(System.in);
  8.         System.out.println("enter your number of inputs");
  9.         int numberOfInputs = s.nextInt();
  10.         int numberOfOdds = 0;
  11.         int numberOfEvens = 0;
  12.        
  13.         for(int i=1; i <= numberOfInputs; i++)
  14.         {
  15.             System.out.println("enter input value");
  16.             int inputValue = s.nextInt();
  17.             if(inputValue%2==0)
  18.             {
  19.                 numberOfEvens++;
  20.             }
  21.             else{
  22.                 numberOfOdds++;
  23.             }
  24.            
  25.         }
  26.        
  27.         System.out.println(numberOfEvens + " is the number of even inputs");
  28.         System.out.println(numberOfOdds + " is the number of odd inputs");
  29.  
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment