Anda di halaman 1dari 21

INSTITUTO TECNOLOGICO SUPERIOR DE SAN ANDRES TUXTLA

ING. SISTEMAS COMPUTACIONALES

TOPICOS AVANZADOS DE LA PROGRAMACION

EVIDENCIAS DE LA UNIDAD 2

JUAN JOSE MARIA PEREZ

GRUPO: 404-B ING. ANGELINA MARQUEZ JIMENEZ 08 / 04 / 2013

PROGRAMA 1 Operaciones.java
import javax.swing.JOptionPane;

public class Operaciones { public static void main(String[]args) { int res=0, opcion; int number1=0; int number2=0; do{ String menu=JOptionPane.showInputDialog(null,"Selecione el numero de la operacion que desea realizar\n"+ "1.- Sumar dos numeros enteros\n"+ "2.- Restar dos numeros enteros\n"+ "3.- Multiplicar dos numeros enteros\n"+ "4.- Dividir dos numeros enteros\n"+ "5.- Finalizar el programa"); opcion=Integer.parseInt(menu); if(opcion==5) { JOptionPane.showMessageDialog(null, "ESTE PROGRAMA HA TERMINADO!!!"); System.exit(0); } if((opcion>=1)&&(opcion<=4)) { String firstNumber=JOptionPane.showInputDialog("Teclea el primer entero"); String secondNumber=JOptionPane.showInputDialog("Teclea el segundo entero"); number1=Integer.parseInt(firstNumber); number2=Integer.parseInt(secondNumber); } switch(opcion) { case 1: res=number1+number2; break; case 2: res=number1-number2; break; case 3: res=number1*number2; break;

case 4: res=number1/number2; break; default: JOptionPane.showMessageDialog(null, "Numero fuera de rango "," Error ", JOptionPane.ERROR_MESSAGE); } if((opcion>=1)&&(opcion<=4)) { JOptionPane.showMessageDialog(null,"El resultado es: "+res,"Operaciones",JOptionPane.PLAIN_MESSAGE); } } while (opcion!=5); } }

GUA DE OBSERVACIN
INSTRUCCIONES Revisar los documentos o actividades que se solicitan y marque en los apartados SI cuando la evidencia a evaluar se cumpla, en caso contrario marque NO. En la columna OBSERVACIONES, ocpela cuando tenga que hacer comentarios referentes a lo observado. Asignatura : TPICOS AVANZADOS DE PROGRAMACIN No. De Equipo : 0 Tema: Programacin de Interfaz Grfica de usuario

Alumno : JUAN JOSE MARIA PEREZ CARACTERSTICAS A CUMPLIR Desarrollo Emplea Listeners Emplea JFrame y JButton en el programa Emplea la librera awt o swing en su programa

CUMPLE SI NO 3% 3% 3%

OBSERVACIONES

CARACTERSTICAS A CUMPLIR
Resultados:

CUMPLE SI NO

OBSERVACIONES

El programa se ejecuta correctamente 3% sin errores sintcticos.


Responsabilidad:

Termin el programa en el tiempo 3% sealado. TOTAL DE REACTIVOS: 15%

15%

Programa 2 Entrada2.java
import javax.swing.*; import java.awt.event.*; public class Entrada2 extends JFrame implements ActionListener { private JTextField campoTxt, campoTxt2; private JLabel etiqueta1, etiqueta2, etiqueta3; private JButton botonAceptar, botonLimpiar; int n1=0,n2=0; int sum=0; public Entrada2() { setLayout(null); etiqueta1 = new JLabel ("Dato 1 : "); etiqueta1.setBounds (30, 20, 100, 30); add(etiqueta1); etiqueta2 = new JLabel ("Dato 2 : "); etiqueta2.setBounds (30, 70, 100, 30); add(etiqueta2); etiqueta3 = new JLabel ("Resultado = "); etiqueta3.setBounds (30, 100, 350, 30); add(etiqueta3); campoTxt = new JTextField (); campoTxt.setBounds (100, 20, 100, 20); add(campoTxt); campoTxt2 = new JTextField (); campoTxt2.setBounds (100, 70, 100, 20); add(campoTxt2); botonAceptar = new JButton ("Aceptar"); botonAceptar.setBounds (10, 150, 100, 30); add(botonAceptar); botonAceptar.addActionListener(this); botonLimpiar = new JButton ("Limpiar"); botonLimpiar.setBounds (120, 150, 100, 30); add(botonLimpiar); botonLimpiar.addActionListener(this); }

public boolean isVacio(String datoFuente) { if(datoFuente.length()==0) return(true); else return(false); } public boolean NoesNumerico(String datoFuente) { try{ Integer.parseInt(datoFuente); return(false); }catch(NumberFormatException er) { return(true); }//su devuelve true sign. q hubo un error al combertir a entero. } public boolean validacion(String fuente1,String fuente2) { boolean band=false;//singnifica q no hay errores if(isVacio(fuente1)) { JOptionPane.showMessageDialog(null,"falto insertar dato 1 ","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if (isVacio(fuente2)) { JOptionPane.showMessageDialog(null,"falto insertar dato 2 ","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if(NoesNumerico(fuente1)) { JOptionPane.showMessageDialog(null,"El dato no es numerico 1","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if(NoesNumerico(fuente2)) { JOptionPane.showMessageDialog(null,"El dato no es numerico 2","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true;

} return band; }

public void actionPerformed(ActionEvent e) { if(e.getSource() == botonAceptar) { if(validacion(campoTxt.getText(),campoTxt2.getText())==false) { String num1 = campoTxt.getText(); n1 = Integer.parseInt(num1); String num2 = campoTxt2.getText(); n2 = Integer.parseInt(num2); sum =n1+n2; setTitle("La suma es "); etiqueta3.setText("El resultado es "+sum); } } if(e.getSource() == botonLimpiar) { setTitle("La suma es "); campoTxt.setText(null); campoTxt2.setText(null); etiqueta3.setText("El resultado es "); } } public static void main(String [] arg) { Entrada2 ent = new Entrada2(); ent.setBounds (0, 0, 300, 250); ent.setVisible (true); ent.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } }

GUA DE OBSERVACIN
INSTRUCCIONES Revisar los documentos o actividades que se solicitan y marque en los apartados SI cuando la evidencia a evaluar se cumpla, en caso contrario marque NO. En la columna OBSERVACIONES, ocpela cuando tenga que hacer comentarios referentes a lo observado. Asignatura : TPICOS AVANZADOS DE PROGRAMACIN No. De Equipo : 0 Tema: Programacin de Interfaz Grfica de usuario

Alumno : JUAN JOSE MARIA PEREZ CARACTERSTICAS A CUMPLIR Desarrollo Emplea Listeners Emplea JFrame y JButton en el programa Emplea la librera awt o swing en su programa

CUMPLE SI NO 3% 3% 3%

OBSERVACIONES

CARACTERSTICAS A CUMPLIR
Resultados:

CUMPLE SI NO

OBSERVACIONES

El programa se ejecuta correctamente 3% sin errores sintcticos.


Responsabilidad:

Termin el programa en el tiempo 3% sealado. TOTAL DE REACTIVOS: 15%

15%

Programa 3 MiniCalc.java
import javax.swing.*; import java.awt.event.*; public class MiniCalc extends JFrame implements ActionListener { private JTextField campoTxt, campoTxt2; private JLabel etiqueta1, etiqueta2, etiqueta3; private JButton botonAceptar, botonLimpiar,botonR,botonD,botonM; double n1=0,n2=0; double r=0; public MiniCalc() { setTitle("Mini Calculadora "); setLayout(null); etiqueta1 = new JLabel ("Dato 1 : "); etiqueta1.setBounds (30, 20, 100, 30); add(etiqueta1); etiqueta2 = new JLabel ("Dato 2 : "); etiqueta2.setBounds (30, 45, 100, 30); add(etiqueta2); etiqueta3 = new JLabel ("Resultado = "); etiqueta3.setBounds (30, 80, 350, 30); add(etiqueta3); campoTxt = new JTextField (); campoTxt.setBounds (100, 20, 100, 20); add(campoTxt); campoTxt2 = new JTextField (); campoTxt2.setBounds (100, 45, 100, 20); add(campoTxt2); botonR = new JButton ("-"); botonR.setBounds (60, 120, 50, 30); add(botonR); botonR.addActionListener(this); botonM = new JButton ("*"); botonM.setBounds (110,120, 50, 30); add(botonM); botonM.addActionListener(this);

botonD = new JButton ("/"); botonD.setBounds (160, 120, 50, 30); add(botonD); botonD.addActionListener(this); botonAceptar = new JButton ("+"); botonAceptar.setBounds (10, 120, 50, 30); add(botonAceptar); botonAceptar.addActionListener(this); botonLimpiar = new JButton ("CE"); botonLimpiar.setBounds (210, 120, 50, 30); add(botonLimpiar); botonLimpiar.addActionListener(this); } public boolean isVacio(String datoFuente) { if(datoFuente.length()==0) return(true); else return(false); } public boolean NoesNumerico(String datoFuente) { try{ Double.parseDouble(datoFuente); return(false); }catch(NumberFormatException er) { return(true); }//su devuelve true sign. q hubo un error al combertir a entero. } public boolean validacion(String fuente1,String fuente2) { boolean band=false;//singnifica q no hay errores if(isVacio(fuente1)) { JOptionPane.showMessageDialog(null,"falto insertar dato 1 ","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if (isVacio(fuente2)) {

JOptionPane.showMessageDialog(null,"falto insertar dato 2 ","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if(NoesNumerico(fuente1)) { JOptionPane.showMessageDialog(null,"El dato no es numerico 1","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if(NoesNumerico(fuente2)) { JOptionPane.showMessageDialog(null,"El dato no es numerico 2","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } return band; } public void actionPerformed(ActionEvent e) { if(e.getSource() == botonAceptar) { if(validacion(campoTxt.getText(),campoTxt2.getText())==false) { String num1 = campoTxt.getText(); n1 = Double.parseDouble(num1); String num2 = campoTxt2.getText(); n2 = Double.parseDouble(num2); r =n1+n2; etiqueta3.setText("El resultado es "+r); } } if(e.getSource() == botonR) { if(validacion(campoTxt.getText(),campoTxt2.getText())==false) { String num1 = campoTxt.getText(); n1 = Double.parseDouble(num1); String num2 = campoTxt2.getText(); n2 = Double.parseDouble(num2); r=n1-n2; etiqueta3.setText("El resultado es "+r);

} } if(e.getSource() == botonM) { if(validacion(campoTxt.getText(),campoTxt2.getText())==false) { String num1 = campoTxt.getText(); n1 = Double.parseDouble(num1); String num2 = campoTxt2.getText(); n2 = Double.parseDouble(num2); r=n1*n2; etiqueta3.setText("El resultado es "+r); } } if(e.getSource() == botonD) { if(validacion(campoTxt.getText(),campoTxt2.getText())==false) { String num1 = campoTxt.getText(); n1 = Double.parseDouble(num1); String num2 = campoTxt2.getText(); n2 = Double.parseDouble(num2); r=n1/n2; etiqueta3.setText("El resultado es "+r); } } if(e.getSource() == botonLimpiar) { campoTxt.setText(null); campoTxt2.setText(null); etiqueta3.setText("Resultado ="); } } public static void main(String [] arg) { MiniCalc ent = new MiniCalc(); ent.setBounds (500, 250, 300, 200); ent.setVisible (true); ent.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } }

GUA DE OBSERVACIN
INSTRUCCIONES Revisar los documentos o actividades que se solicitan y marque en los apartados SI cuando la evidencia a evaluar se cumpla, en caso contrario marque NO. En la columna OBSERVACIONES, ocpela cuando tenga que hacer comentarios referentes a lo observado. Asignatura : TPICOS AVANZADOS DE PROGRAMACIN No. De Equipo : 0 Tema: Programacin de Interfaz Grfica de usuario

Alumno : JUAN JOSE MARIA PEREZ CARACTERSTICAS A CUMPLIR Desarrollo Emplea Listeners Emplea JFrame y JButton en el programa Emplea la librera awt o swing en su programa

CUMPLE SI NO 3% 3% 3%

OBSERVACIONES

CARACTERSTICAS A CUMPLIR
Resultados:

CUMPLE SI NO

OBSERVACIONES

El programa se ejecuta correctamente 3% sin errores sintcticos.


Responsabilidad:

Termin el programa en el tiempo 3% sealado. TOTAL DE REACTIVOS: 15%

15%

Programa 4 Hipoteca.java
import javax.swing.*; import java.awt.event.*; public class Hipoteca extends JFrame implements ActionListener { private JTextField campotxt, campotxt2, campotxt3; private JLabel etiqueta1, etiqueta2, etiqueta3, etiqueta4; private JButton botonCalcular, botonLimpiar; double n1=0, n2=0,n3=0; double r; public Hipoteca() { setTitle("Calculo de la Cuota Mensual de la Hipoteca "); setLayout(null); etiqueta1 = new JLabel ("Cantidad $ : "); etiqueta1.setBounds (30, 20, 100, 30); add(etiqueta1); campotxt = new JTextField (); campotxt.setBounds (100, 25, 80, 20); add(campotxt); etiqueta2 = new JLabel ("Aos : "); etiqueta2.setBounds (190, 20, 100, 30); add(etiqueta2); campotxt2 = new JTextField (); campotxt2.setBounds (230, 25, 60, 20); add(campotxt2); etiqueta3 = new JLabel ("Interes Mensual : "); etiqueta3.setBounds (310, 20, 100, 30); add(etiqueta3); campotxt3 = new JTextField (); campotxt3.setBounds (410, 25, 80, 20); add(campotxt3); etiqueta4 = new JLabel ("Cuota mensual a pagar : "); etiqueta4.setBounds (30, 50, 250, 30); add(etiqueta4); botonCalcular = new JButton ("Calcular"); botonCalcular.setBounds (20, 80, 100, 30); add(botonCalcular); botonCalcular.addActionListener(this);

botonLimpiar = new JButton ("Limpiar"); botonLimpiar.setBounds (140, 80, 100, 30); add(botonLimpiar); botonLimpiar.addActionListener(this); } public boolean isVacio(String datoFuente) { if(datoFuente.length()==0) return(true); else return(false); } public boolean NoesNumerico(String datoFuente) { try{ Double.parseDouble(datoFuente); return(false); }catch(NumberFormatException er) { return(true); } } public boolean validacion(String fuente1,String fuente2,String fuente3) { boolean band=false; if(isVacio(fuente1)) { JOptionPane.showMessageDialog(null,"falto insertar dato 1 ","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if (isVacio(fuente2)) { JOptionPane.showMessageDialog(null,"falto insertar dato 2 ","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if (isVacio(fuente3)) { JOptionPane.showMessageDialog(null,"falto insertar dato 3 ","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; }

if(NoesNumerico(fuente1)) { JOptionPane.showMessageDialog(null,"El dato no es numerico 1","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if(NoesNumerico(fuente2)) { JOptionPane.showMessageDialog(null,"El dato no es numerico 2","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } if(NoesNumerico(fuente3)) { JOptionPane.showMessageDialog(null,"El dato no es numerico 3","!!!Atencion",JOptionPane.ERROR_MESSAGE); band=true; } return band; } public void actionPerformed(ActionEvent e) { if(e.getSource() == botonCalcular) { if(validacion(campotxt.getText(),campotxt2.getText(),campotxt3.getText())==false) { String num1 = campotxt.getText(); n1 = Double.parseDouble(num1); String num2 = campotxt2.getText(); n2 = Double.parseDouble(num2); String num3 = campotxt3.getText(); n3 = Double.parseDouble(num3); r =(n1*n2*(n3/100))/(12*n2); etiqueta4.setText("Cuota mensual a pagar : "+r); } } if(e.getSource() == botonLimpiar) { campotxt.setText(null); campotxt2.setText(null); campotxt3.setText(null); etiqueta4.setText("Cuota mensual a pagar : "); } }

public static void main(String [] arg) { Hipoteca hip = new Hipoteca(); hip.setBounds (0, 0, 510, 160); hip.setVisible (true); hip.setResizable(false); hip.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } }

GUA DE OBSERVACIN
INSTRUCCIONES Revisar los documentos o actividades que se solicitan y marque en los apartados SI cuando la evidencia a evaluar se cumpla, en caso contrario marque NO. En la columna OBSERVACIONES, ocpela cuando tenga que hacer comentarios referentes a lo observado. Asignatura : TPICOS AVANZADOS DE PROGRAMACIN No. De Equipo : 0 Tema: Programacin de Interfaz Grfica de usuario

Alumno : JUAN JOSE MARIA PEREZ CARACTERSTICAS A CUMPLIR Desarrollo Emplea Listeners Emplea JFrame y JButton en el programa Emplea la librera awt o swing en su programa

CUMPLE SI NO 3% 3% 3%

OBSERVACIONES

CARACTERSTICAS A CUMPLIR
Resultados:

CUMPLE SI NO

OBSERVACIONES

El programa se ejecuta correctamente 3% sin errores sintcticos.


Responsabilidad:

Termin el programa en el tiempo 3% sealado. TOTAL DE REACTIVOS: 15%

15%

Anda mungkin juga menyukai