It is currently Wed Sep 08, 2010 9:02 pm

All times are UTC




 Page 1 of 1 [ 1 post ] 
Author Message
 Post subject: Numeros primos
PostPosted: Thu Sep 03, 2009 7:02 pm 
Newbie
Newbie

Joined: Thu Sep 03, 2009 6:22 pm
Posts: 6
main
package primo;

public class Aplicacion {
   public static void main(String[] args) {
      Numero b=new Numero();
      b.entrada();
      b.salida();
   }
}

Numero
package primo;
import javax.swing.JOptionPane;
public class Numero {
   private int n;
   private int d=2;

   public void entrada(){
      n=Integer.parseInt(JOptionPane.showInputDialog("Numero"));
   }
   public void salida(){
      if(n==1)
         JOptionPane.showMessageDialog(null, "Numero Unitario");
      else
         while(d<=n)
         { 
            while(n%d!=0)
               d=d+1;
            if(n==d)                               
               JOptionPane.showMessageDialog(null, "Es primo");
            else
               JOptionPane.showMessageDialog(null, "No es primo");
            break;
         }    
   }
}








Bueno por el dia de hoy son todos, saludos... despues mando mas... creo q tengo bastantes.


Offline
 Profile Send private message  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

cron