To Check Whether Number is Armsrong no. or not

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
 {                                       
       
        int N = Integer.parseInt(t1.getText());
        int a1 = N;
        int q,r,c=0;
        while (N!=0)
         {
            q= N/10;
            r=N%10;
            N=q;
            c= c+(r*r*r);
          }
        if (a1==c)
            R.setText("An Amstrong Number");
        else
            R.setText("Not an Amstrong Number");
    }


Comments

Popular posts from this blog

Xtra Care Hospital Bill Generator

Net Beans Program to Check Given Number Is Palladrom Number or Not

Net Beans program To Check Whether Given Number is Armsrong no. or not