To Check a Number Whether is it Prime or Not.











      
private void CheckButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
             int N= Integer.parseInt(t1.getText());
             int i;

             for(i=2;i<=N/2;i++)
                   {
                                if(N%i==0)
                                         {        r.setText("Not a Prime No. ");
                                                  break;
                                           }
                   }

            if(i>N/2)
             r.setText("Prime No. ");
     
    }                                          

private void ClearButtonActionPerformed(java.awt.event.ActionEvent evt)      
    {                                            
                        t1.setText("");
                         r.setText("");
    }


Comments

Popular posts from this blog

Xtra Care Hospital Bill Generator

Net Beans Program to Check a Number Whether is it Prime or Not.

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