Advertisement
Guest User

OddOrEven

a guest
Sep 2nd, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. package Exercises;
  2.  
  3. import java.util.*;
  4.  
  5. public class OddOrEven {
  6.  
  7.     public static void main(String[] args)
  8.     {
  9.  
  10.         Scanner input = new Scanner(System.in);
  11.        
  12.         int a = 8, b = 2, c = 3;
  13.         int total = a%b;
  14.         int total2 = a%c;
  15.        
  16.         System.out.print("Enter a number: ");   //prompt
  17.         total = input.nextInt();    //read # from user
  18.        
  19.         if((a%b) == 0)
  20.             System.out.printf("Your number is even.", total);
  21.         if((a%c) != 0)
  22.             System.out.printf("Your number is odd.", total2);
  23.        
  24.  
  25.  
  26.     }//end method main
  27.  
  28. }//end class OddOrEven
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement