Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /* ==================================================
- Chapter 2: Syntax section A- conditional clause
- Ex3: identical digit in a double-digit number
- ===================================================
- */
- public class MyProgram {
- public static void main(String[] args) {
- //variables
- int number;
- int tmp; //keeping the number intact
- byte digit;
- Scanner s=new Scanner(System.in);
- //user input: we can assume the input is valid
- System.out.println("Enter a Double-digit number: ");
- number=s.nextInt();
- //check digits display message
- if(number%10==number/10)
- System.out.println("Identical digits!");
- else
- System.out.println("NOT identical!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment