InterviewSolution
Saved Bookmarks
| 1. |
Write a menu driven program to check whether it is 4 digit number or not |
|
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"); } } |
|