Pages

Adsense responsive

Saturday, 9 March 2013

JAVA PROGRAM: TO REVERSE A NUMBER


HEADER FILE
        import javax.swing.JOptionPane;



CODING OF REVERSE BUTTON(jButton1)
        int num,temp,rev = 0;
        num=Integer.parseInt(jTextField1.getText());
        if(num<10)
        {
         JOptionPane.showMessageDialog(null,"Enter a number greater than 9");
         jTextField1.setText("");
        }
        else
        {
         while(num>0)
         {
          temp=num%10;
          rev=temp+10*rev;
          num=num/10;
         }
         jTextField2.setText(" "+rev);
        }

CODING OF CLEAR BUTTON(jButton2)
        jTextField1.setText(" ");
        jTextField2.setText(" ");
   

CODING OF EXIT BUTTON(jButton3)

        System.exit(0);

CODING

RUNNING

RUNNING

We have used NetBeans IDE 7.2.1. To download it visit www.netbeans.org


For any query or suggestion please comment below...

No comments:

Post a Comment