lunes, 23 de septiembre de 2013

Sesión 4 Java II

FORMULARIO



EJECUCIÓN



BOTONES






























                                         EJECUCIÓN


ENLAZAR FORMULARIOS


EJECUCIÓN




MENÚ OPERACIONES



EJECUCIÓN




Elaborado por:

Javier Castaño
Yuly Sánchez
Fredy Olaya






martes, 17 de septiembre de 2013

Sesión 3 Java II


JFRAME

















EJECUCIÓN


CONVERSOR CELSIUS



EJECUCIÓN


ÁREA DEL TRIÁNGULO


EJECUCIÓN














































































Sesión 2 Java II

ÚLTIMO

package ultimo;

import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.BoxLayout;
import javax.swing.WindowConstants;

public class ULTIMO{
JFrame frame;
JPanel panelSuperior, panelInferior;
JButton bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9, bt0, btRT, btCE, btCL, btMas, btMenos, btMul, btDiv, btIgual, btMN, btPunto;
 JTextField pantalla;
public ULTIMO(){
construyePanelSuperior();
 construyePanelInferior();
construyeVentana();}

void construyePanelSuperior(){
panelSuperior = new JPanel ();
panelSuperior.setLayout(new FlowLayout());
pantalla = new JTextField(20);
panelSuperior.add(pantalla);}
void construyePanelInferior(){
panelInferior= new JPanel();
panelInferior.setLayout(new GridLayout(5,4,8,8));
bt1=new JButton("1");
bt2=new JButton("2");
bt3=new JButton("3");
bt4=new JButton("4");
bt5=new JButton("5");
bt6=new JButton("6");
bt7=new JButton("7");
bt8=new JButton("8");
bt9=new JButton("9");
bt0=new JButton("0");
btRT=new JButton("Rtc");
btCE=new JButton("CE");
btCL=new JButton("CL");
btMas=new JButton("+");
btMenos=new JButton("-");
btMul=new JButton("x");
btDiv=new JButton("/");
btIgual=new JButton("=");
btMN=new JButton("+/-");
btPunto=new JButton(".");
panelInferior.add(btRT);
panelInferior.add(btCE);
panelInferior.add(btCL);
panelInferior.add(btMN);
panelInferior.add(bt7);
panelInferior.add(bt8);
panelInferior.add(bt9);
panelInferior.add(btDiv);
panelInferior.add(bt4);
panelInferior.add(bt5);
panelInferior.add(bt6);
panelInferior.add(btMul);
panelInferior.add(bt1);
panelInferior.add(bt2);
panelInferior.add(bt3);
panelInferior.add(btMenos);
panelInferior.add(bt0);
panelInferior.add(btPunto);
panelInferior.add(btIgual);
panelInferior.add(btMas);}

void construyeVentana(){
 frame =new JFrame("Calculadora ");
frame.setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS));
frame.add(panelSuperior);
frame.add(panelInferior);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);}

public static void main(String [] inforux){
new ULTIMO();
}
 }

EJECUCIÓN
























GRIDLAYOUT


EJECUCIÓN


EJERCICIOS CARTILLAS


EJECUCIÓN




EJECUCIÓN





EJECUCIÓN



CLASE BOX


EJECUCIÓN








lunes, 16 de septiembre de 2013

Sesión 1 Java II



SUMA Y RESTA DE VECTORES
























EJECUCIÓN

































SUMA Y RESTA DE MATRICES


EJECUCIÓN


MENÚ SWITCH

package metodoscodigos;

import javax.swing.JOptionPane;

public class Metodoscodigos {

    public static void main(String[] args) {


        menu();

    }

    public static void menu() {

        int menu;
        try {
            do {


                menu = Integer.parseInt(JOptionPane.showInputDialog("INGRESE LA OPCION PARA EJECUTAR EL PROGRAMA DESEADO"
                        + "\n 1. Factorial de un numero"
                        + "\n 2. Acumulado y Promedio de un numero"
                        + "\n 3. Potencia de un numero"
                        + "\n 4. Suma y resta de vectores"
                        + "\n 5. Suma y resta de matrices"
                        + "\n 6. Tablas de multiplicar"
                        + "\n 7. Fin del Programa" + JOptionPane.QUESTION_MESSAGE));

                switch (menu) {
                    case 1:
                        factorial();
                        break;
                    case 2:
                        promedio();
                        break;
                    case 3:
                        potencia();
                        break;
                    case 4:
                        vectores();
                        break;
                    case 5:
                        matrices();
                        break;
                    case 6:
                        tablasmul();
                        break;
                    case 7:
                        menu = 7;
                        break;
                }
            } while (menu != 7);


        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "ERROR" + e.getMessage(), "mensaje", JOptionPane.ERROR_MESSAGE);
        } finally {
        }
    }

//factorial.
    public static void factorial() {
        int n, mul, fac;
        String s;

        s = JOptionPane.showInputDialog(null, "INGRESE EL NUMERO AL CUAL DESEA VER SU FACTORIAL  ");
        n = Integer.parseInt(s);



        for (int m = 0; m <= n; m++) {

            mul = n * m;
            fac = mul * n;
            JOptionPane.showMessageDialog(null, +fac);

        }
    }

    // acomulado y promedio
    public static void promedio() {


        int i = 0, suma = 0, num, cant, sum;
        String s;

        s = JOptionPane.showInputDialog(null, "INGRESE LA CANTIDAD DE NUMEROS QUE DESEA SUMAR Y ACUMULAR  ");
        cant = Integer.parseInt(s);



        while (i < cant) {
            s = JOptionPane.showInputDialog(null, "INGRESE  NUMERO");
            num = Integer.parseInt(s);
            suma = suma + num;
            i++;

        }
        JOptionPane.showMessageDialog(null, +suma);
    }

    //potencia
    public static void potencia() {


        int n, ex, pot;
        String s;

        s = JOptionPane.showInputDialog(null, "INGRESE UN NUMERO  ");
        n = Integer.parseInt(s);

        s = JOptionPane.showInputDialog(null, "INGRESE LA POTENCIA CON LA CUAL DESEA ELEVAR EL NUMERO ");
        ex = Integer.parseInt(s);

        JOptionPane.showMessageDialog(null, +Math.pow(n, ex));

    }

    // suma y resta de vectores.
    public static void vectores() {

        int i, j, k, f;

        String s;

        s = JOptionPane.showInputDialog(null, "Introduce el tamaño de los vectores");
        f = Integer.parseInt(s);

        int v[] = new int[f];
        int w[] = new int[f];
        int R[] = new int[f];


        JOptionPane.showMessageDialog(null, "Introduce los valores del vector V: ");
        for (i = 0; i < f; i++) {
            s = JOptionPane.showInputDialog(null, "V [" + i + "]=");
            v[i] = Integer.parseInt(s);
        }

        JOptionPane.showMessageDialog(null, "Introduce los valores del vector W: ");
        for (j = 0; j < f; j++) {

            s = JOptionPane.showInputDialog(null, "W [" + j + "]=");
            w[j] = Integer.parseInt(s);

        }


        for (k = 0; k < f; k++) {
            R[k] = v[k] + w[k];

        }

        JOptionPane.showMessageDialog(null, "El vector resultante de la suma  es: ");
        for (k = 0; k < f; k++) {
            JOptionPane.showMessageDialog(null, R[k] + "\t");

        }
        for (k = 0; k < f; k++) {
            R[k] = v[k] - w[k];

        }

        JOptionPane.showMessageDialog(null, "El vector resultante de la resta es: ");
        for (k = 0; k < f; k++) {
            JOptionPane.showMessageDialog(null, R[k] + "\t");

        }
    }

    // SUMA Y RESTA DE MATRICES
    public static void matrices() {
        int i, j, k, f, m, a;

        String s;

        s = JOptionPane.showInputDialog(null, "Introduce el tamaño de la fila");
        f = Integer.parseInt(s);
        s = JOptionPane.showInputDialog(null, "Introduce el tamaño de la columna");
        k = Integer.parseInt(s);

        int v[][] = new int[f][k];
        int w[][] = new int[f][k];
        int sum[][] = new int[f][k];
        int res[][] = new int[f][k];

        for (i = 0; i < f; i++) {
            for (j = 0; j < k; j++) {
                v[i][j] = i + 1;
            }
        }
        for (i = 0; i < f; i++) {
            for (j = 0; j < k; j++) {
                System.out.print(v[i][j] + "\t|");
            }
            System.out.println();

        }

        for (i = 0; i < f; i++) {
            for (j = 0; j < k; j++) {
                w[i][j] = i + 1;
            }
        }
        for (i = 0; i < f; i++) {
            for (j = 0; j < k; j++) {
                System.out.print(w[i][j] + "\t|");
            }
            System.out.println();

        }
        for (i = 0; i < f; i++) {
            for (j = 0; j < k; j++) {
                sum[i][j] = v[i][j] + w[i][j];
            }
        }
        for (i = 0; i < f; i++) {
            for (j = 0; j < k; j++) {
                System.out.print(sum[i][j] + "\t|");
            }
            System.out.println();



        }
        for (i = 0; i < f; i++) {
            for (j = 0; j < k; j++) {
                res[i][j] = v[i][j] - w[i][j];
            }
        }
        for (i = 0; i < f; i++) {
            for (j = 0; j < k; j++) {
                System.out.print(res[i][j] + "\t|");
            }
            System.out.println();
        }
    }

    // TABLAS DE MULTIPLICAR

    public static void tablasmul() {

        int resultado, i, j;

        for (i = 1; i <= 10; i++) {
            for (j = 1; j <= 10; j++) {
                JOptionPane.showMessageDialog(null, i + "*" + j + "=" + i * j);

            }
        }
    }
}

EJECUCIÓN



Elaborado por:

Javier Castaño
July Sánchez
Fredy Olaya