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
Computer Science,
1 month ago
Hindi,
1 month ago
Political Science,
2 months ago
Math,
10 months ago
Social Sciences,
10 months ago
Math,
10 months ago