Write a menu driven program to check whether it is 4 digit number or not
Answers
Answered by
1
Answer:
import java.io.*;
{
public static void main (String arg[])throws Exception
{
int R,n,ctr;
DataInputStream in=new DataInputStream(System.in);
System.out.println("enter the number");
n=Integer.parseInt(in.readLine());
ctr=0
while(n>0)
{
R=n%10;
n=n/10;
if(R>=0)
ctr++;
}
if(ctr==4)
System.out.println("it is a four digit number");
else
System.out.println("it is not a four digit number");
}
}
Similar questions
Science,
9 days ago
Math,
9 days ago
Political Science,
18 days ago
Math,
8 months ago
Social Sciences,
8 months ago
Math,
8 months ago