write a java program to take a 2-digit number from user and state whether it is a 2-digit number or not.if it is a 2-digit number then seperate the 1st and 2nd number from each other.
Answers
Answered by
0
Answer:
Program:-
import java.util.*;
public class Two_Digit
{
public static void main(String args[ ])
{
Scanner in=new Scanner(System.in);
int n=0,num=0,a=0,r=0;
System.out.println("Enter the number");
n=in.nextInt();
if(n>=10&&n<100)
{
System.out.println("A two digit number");
num=n;
while(n!=0)
{
a=n%10;
n=n/10;
}
System.out.println("The first digit="+a);
r=num%10;
System.out.println("The last digit="+r);
}
else
System.out.println("Entered number is not a two digit number");
}
}
Similar questions