hpilo

Chapter2_SyntaxA_Ex3

Dec 15th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. /*  ==================================================
  5.      Chapter 2: Syntax section A- conditional clause
  6.  
  7.       Ex3: identical digit in a double-digit number
  8.     ===================================================
  9. */
  10.  
  11.  
  12. public class MyProgram {
  13.     public static void main(String[] args) {
  14.  
  15.         //variables
  16.         int number;
  17.         int tmp;       //keeping the number intact
  18.         byte digit;
  19.         Scanner s=new Scanner(System.in);
  20.  
  21.         //user input:   we can assume the input is valid
  22.         System.out.println("Enter a Double-digit number: ");
  23.         number=s.nextInt();
  24.  
  25.         //check digits display message
  26.         if(number%10==number/10)
  27.             System.out.println("Identical digits!");
  28.         else
  29.             System.out.println("NOT identical!");
  30.  
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment