Advertisement
Shavit

IfEven

Nov 16th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class IfEven {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         int num;
  12.         int numInList;
  13.         boolean isEven;
  14.        
  15.         Scanner in = new Scanner (System.in);
  16.        
  17.         System.out.print("Enter the first nunmber:");
  18.         num = in.nextInt();
  19.        
  20.         if(num % 3 == 0)
  21.             isEven = true;
  22.         else
  23.             isEven = false;
  24.        
  25.         System.out.print("Enter a number. Enter 0 to end the list: ");
  26.         numInList = in.nextInt();
  27.         while(numInList != 0)
  28.         {
  29.             if(isEven)
  30.             {
  31.                 if(numInList % 3 == 0)
  32.                     System.out.print(numInList + "\n");
  33.             }
  34.            
  35.             else
  36.                 System.out.print(numInList + "\n");
  37.            
  38.             System.out.print("Enter the next number. Enter 0 to end the list: ");
  39.             numInList = in.nextInt();
  40.         }
  41.        
  42.         in.close();
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement