keymasterviriya1150

Quiz1

Sep 28th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. import java.util.*;
  2. public  class Test  {
  3.  
  4.     public static void main(String[] args) {
  5.        
  6.  
  7.         Scanner sc = new Scanner(System.in);  
  8.  
  9.  
  10.             while(true){
  11.                 System.out.print("Enter first number >>>");
  12.                 int x = sc.nextInt();
  13.                 System.out.print("Enter last number >>>");
  14.                 int y= sc.nextInt();
  15.                 if ( x == 0 && y == 0 )
  16.                     break;
  17.                 if( x < y) {
  18.                     System.out.println("First number > Last number ");
  19.                 }
  20.                 else if (x > y) {
  21.                     System.out.println("First number > Last number == Error ");
  22.                 }
  23.  
  24.                 System.out.println("press 1  for 3 or 5");
  25.                 System.out.println("press 2  for 5 or 7");
  26.  
  27.                 int pick = sc.nextInt();
  28.                 if(pick == 1){
  29.                     for(int i=x ; i <= y ;i++){
  30.                         if( i%3 == 0 ||   i%5 == 0){
  31.                              System.out.print(i+" ");
  32.                         }
  33.                     }
  34.                 }
  35.                 else if(pick == 2){
  36.                    for(int i=x ; i <= y ;i++){
  37.                         if( i%5  == 0  ||  i%7 == 0){
  38.                              System.out.print(i+" ");
  39.                         }
  40.                      
  41.                     }
  42.                 }
  43.                 else {
  44.                     System.out.println("No have choice (1 or 2)");
  45.                 }
  46.                  System.out.println("");
  47.             }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment