Computer Science, asked by prathamd3, 18 days ago

Write a menu driven program to check whether it is 4 digit number or not

Answers

Answered by sanchit20022005
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