Check User Enter Number is Special Two Digit Number OR Not?

In this article, we are trying to solve the user-entered number is a special two digit number or not.
! Important Note:- Before learning Programming you need to know about Java Basic Concepts(click here to learn).
First of all, learn about java Scanner Class in short.

import java.util.Scanner;
  • A Scanner is a Class of Java.util Package used for Obtaining the Input of  Primitive Data Type like -int, double, long, etc.
  • Scanner Class is the easiest way to Read the input of Java Program.
  • To Create an Object of Scanner Class, we Usually Pass the Predefine Object (System.in). Which is represent the Standard input stream, we may Pass an Object of Class file. if we want to read from a file.
  • always Scanner Class Saved with the extension of (Read.java).
"Special Two-Digit Number" "Scanner Class" "import java util scanner" 'scanner" "Scanner class Java"

"Special Two-Digit Number" "Scanner Class" "import java util scanner" 'scanner" "Scanner class Java"

  • nextBoolean( );
  • nextByte( );
  • nextShort( );
  • nextInt( );
  • nextLong( );
  • nextFloat( );
  • nextDouble( );
  • next( );       //Use for Strings
  • nextLine( ); // Use for String Sentence\  etc....

//Qus:- Check User Enter Number is Special Two Digit Number OR not?

Solution:-

 import java.util.Scanner;  
 public class Read_Special_Two_Digit_Number_Or_Not {  
      public static void main(String[] args) {  
           Scanner sc= new Scanner(System.in);  
           System.out.println("Enter the Number Is Special Two Digit or Not");  
           int n = sc.nextInt();  
           //n is User Enter Number for Output  
           int a=n/10;  
           int b=n%10;  
           int c=(a+b)+(a*b);  
           // Formula for Modulus  
           if(c==n)  
                //(If( )) is Conditional Statement  
           {  
                System.out.println(n+" "+"Is Special Two Digit Number");  
           }  
           else  
                System.out.println(n+" "+"Is Not a Special Two Digit Number");  
      }  
 }  

"Special Two-Digit Number" "Scanner Class" "import java util scanner" 'scanner" "Scanner class Java"

🤖Explanation: let's Suppose User Entered Number is (n=29)

Finding the 1st Number of Digit:-
👉 a=n/10
👉 a=29/10
👉 a=2

Remember this note:- in java always integer values give integer after division, it means 29/10=2.9 but in java, we write only 2,  (not point 9) 
                                                   
Finding the 2nd Number of Digit:-

👉b=n%10  (Always Gives Reminder)
👉b=29%10
👉 reminder = 9

Applying Formula :- n=(a+b)+(a*b)
👉  (2+9)+(2*9) = 29

🤙 that means c=29 so according to condition (c=n) the value of c and n are Equals, that why 29 is a Special Two-Digit Number
           

🤦‍♂️Try Your Self Buddy,  If you Get any Error just message me, Definitely, I will try to Solve Your Problem.

Suggestion:- 500+ Java Programs List With Examples and Output.

Admin Words:- I am always tried to solve this program in a simple way. Which helps you to make it easy to understand?  I hope, now you can understand How to find the user enter number is a Special Two Digit Number or not. If you find any error in this program please remind us to comment below of this post.

Next Program:- Check the number is even or odd without modulus?

Recommended: -