bucles FOR en JAVA

package packCasos;

import javax.swing.*;
public class ejemplos {

  //metodos STATICOS
  static void rangoNumeros(){
      String num1,num2;
      int x1,x2,x;
      num1=JOptionPane.showInputDialog("Ingrese Primer Valor :");
      x1=Integer.parseInt(num1);
      num2=JOptionPane.showInputDialog("Ingrese Segundo Valor :");
      x2=Integer.parseInt(num2);
      for (x=x1;x<=x2;x++){
          System.out.println(x);
      }
  }

    static void tablamultiplicar(){
        String num;
        int n1,n,fin;
        num=JOptionPane.showInputDialog("Ingrese Numero de Tabla :");
        n1=Integer.parseInt(num);
        for (n=1;n<=12;n++){
         fin=n*n1;
         System.out.println(n + " * " + n1 + " = " + fin);
        }       
    }
   
     static void Frase(){
      String fra,num;
      int n1,re;
      fra=JOptionPane.showInputDialog("Ingrese Frase :");
      num=JOptionPane.showInputDialog("Ingrese Cantidad a Repetir :");
      n1=Integer.parseInt(num);
      for(re=1;re<=n1;re++){ 
        System.out.println(fra);
      }
    }

    static void operaciones(){
       double x,n1,s,r,m,d;
       n1=Double.parseDouble(JOptionPane.showInputDialog("Ingrese Numero :"));
       for (x=1;x<=12;x++){
           s=n1+x;
           r=n1-x;
           m=n1*x;
           d=n1/x;
           System.out.println(n1+ " + "+x+ " = "+s+" "+ "\t"+
                              n1+ " - "+x+ " = "+r+" "+ "\t"+
                              n1+ " * "+x+ " = "+m+" "+ "\t"+
                              n1+ " / "+x+ " = "+d);
       }
    }

    //metodo MAIN
    public static void main(String[] args) {
       operaciones();
       
    }

}

Comentarios

Entradas populares

Ejercicios Consola Visual Basic.NET

Numero Capicua Visual Basic

Procedimientos Almacenados ORACLE