hpilo

Chapter2_SyntaxB_Ex7

Dec 15th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /*  ==================================================
  4.           Chapter 2: Syntax section B- Loops
  5.  
  6.         Ex7: Triple digit number X7
  7.     ===================================================
  8. */
  9.  
  10.  
  11. public class MyProgram {
  12.     public static void main(String[] args) {
  13.  
  14.         //variables
  15.         int number;
  16.         Scanner s=new Scanner(System.in);
  17.  
  18.         //user input
  19.         System.out.println("\nEnter a Triple digit number X7: ");
  20.         number=s.nextInt();
  21.  
  22.         //loop until Triple digit number multiplied by 7
  23.         while((number<100 || number>999) || number%7!=0) {
  24.             System.out.println("Try again: ");
  25.             number=s.nextInt();
  26.         }
  27.         System.out.println("Triple digit number X7 !\n***End***");
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment