Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. *
  2. * @author davidperona
  3. */
  4. public class MisPruebas {
  5.  
  6. /**
  7. * @param args the command line arguments
  8. */
  9. public static void main(String[] args) {
  10. // TODO code application logic here
  11.  
  12. // int variable=0;
  13. //
  14. // Scanner dameNum = new Scanner(System.in);
  15. //
  16. // System.out.println("Introduce un número: ");
  17. //
  18. // String numero = dameNum.nextLine();
  19. //
  20. // System.out.println("El número introducido es: " + numero);
  21. //
  22. // int entero = Integer.parseInt(numero);
  23.  
  24. do{
  25.  
  26. String dameNum=JOptionPane.showInputDialog("Introduce un número, por favor");
  27.  
  28. //Como Joptionpane no admite enteros hay que hacer un parse int, no una refundición
  29. int num=Integer.parseInt(dameNum);
  30.  
  31. for(int i=1; i<=num; i++){
  32. if(num%i == 0){
  33. System.out.println("El número " + num + " es divisible por " + i);
  34. }
  35. }
  36. }while(num!=0);
  37.  
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement