Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class IfEven {
- public static void main(String[] args)
- {
- int num;
- int numInList;
- boolean isEven;
- Scanner in = new Scanner (System.in);
- System.out.print("Enter the first nunmber:");
- num = in.nextInt();
- if(num % 3 == 0)
- isEven = true;
- else
- isEven = false;
- System.out.print("Enter a number. Enter 0 to end the list: ");
- numInList = in.nextInt();
- while(numInList != 0)
- {
- if(isEven)
- {
- if(numInList % 3 == 0)
- System.out.print(numInList + "\n");
- }
- else
- System.out.print(numInList + "\n");
- System.out.print("Enter the next number. Enter 0 to end the list: ");
- numInList = in.nextInt();
- }
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement