Digit Checker program which checks the digit of the number up to 5 digit.

PROGRAM :

import javax.swing.JOptionPane;
public class DigitCheck {
        public static void main(String[] args) {
       
        int a ;
        String s = JOptionPane.showInputDialog("enter  a number");
        a=Integer.parseInt(s);
        if(a>=0 && a<9)
        { JOptionPane.showMessageDialog(null,"one digit number");
        }
        else if (a>9 && a<99){
        JOptionPane.showMessageDialog(null,"two digit number");
        }
        else if (a>99 && a<999){
        JOptionPane.showMessageDialog(null,"three digit number");
        }
        else if (a>999 && a<9999){
        JOptionPane.showMessageDialog(null,"four digit number");
        }
  else if (a>9999 && a<99999){
         JOptionPane.showMessageDialog(null,"five digit number");
        }
        else 
        JOptionPane.showMessageDialog(null,"more than five digit");
    }
}

No comments:

Post a Comment