You are on page 1of 22

INSTITUTO TECNOLGICO SUPERIOR DE SAN ANDRS TUXTLA

TOPICOS AVANZADOS EN PROGRAMACIN

Evidencia de unidad 2

INTEGRANTE BAXIN PUCHETA ESMERALDA

ANGELINA MARQUEZ JIMENEZ

INGENIERA EN SISTEMAS COMPUTACIONALES 404 A

PROGRAMA 1 SumaInt2.java

import java.io.*; importjavax.swing.JOptionPane; //program uses JOptionPane.

public class SumaInt2 { public static void main (String[] args) { int res=0,n1=0,n2=0,op=0;

//ciclo do { //Mensaje para el men String opcion=JOptionPane.showInputDialog(null, "1.- SUMA \n"+ "2.- RESTA \n"+ "3.- MULTIPLICACIN \n"+ "4.- DIVISIN \n"+ "5.- SALIR","**MENU** \n",JOptionPane.ERROR_MESSAGE);

op=Integer.parseInt(opcion);

if(op==5){ System.exit(0); }

if ((op>=1)&&(op<=4))

{ //obtain user input from JoptionPane input dialogs String firstNumber=JOptionPane.showInputDialog("Teclea el primer entero"); String seconNumber=JOptionPane.showInputDialog("Teclea el segundonumero"); //convert String inputs to int values for use in a calculation

n1=Integer.parseInt(firstNumber); n2=Integer.parseInt(seconNumber); }

switch (op) { case 1: res=n1+n2; break; case 2: res=n1-n2; break; case 3: res=n1*n2; break; case 4: res=n1/n2; break; default: JOptionPane.showMessageDialog(null,"ERROR",

"MENU", JOptionPane.ERROR_MESSAGE); } //end switch

if ((op>=1)&&(op<=4)){ //display result in a JOptionPanemessaje dialog JOptionPane.showMessageDialog(null,"El resultado es.."+res, "MENU", JOptionPane.ERROR_MESSAGE); }

} // fin del ciclo while(op!=5); } //end method main }

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 : Esmeralda Baxin Pucheta

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%

9%

PROGRAMA 2 ENTRADAS2.JAVA
importjavax.swing.*; importjava.awt.event.*; public class Entradas2 extends JFrame implements ActionListener { privateJTextFieldcampoTxt, campoTxt2; privateJLabel etiqueta,etiqueta2,total; privateJButtonbotonAceptar,botonLimpiar; public double suma; public Entradas2() { setLayout(null); etiqueta=new JLabel("Dato 1:"); etiqueta.setBounds(10,10,100,30); add(etiqueta); campoTxt=new JTextField(); campoTxt.setBounds(120,10,80,20); add(campoTxt);

setLayout(null); etiqueta2=new JLabel("Dato 2:"); etiqueta2.setBounds(10,40,100,30); add(etiqueta2); campoTxt2=new JTextField(); campoTxt2.setBounds(120,40,80,20); add(campoTxt2); total=new JLabel("Resultado = "); total.setBounds(10, 70,100,30); add(total); botonAceptar=new JButton("Aceptar"); botonAceptar.setBounds(10,100,100,30); add(botonAceptar); botonAceptar.addActionListener(this); botonLimpiar=new JButton("Limpiar"); botonLimpiar.setBounds(140,100,100, 30); add(botonLimpiar); botonLimpiar.addActionListener(this);

} publicbooleanesVacio(String Datos) { if (Datos.length()==0) return true; else return false; } publicbooleanNoEsNumerico(String Num ) { try { Double.parseDouble(Num); return false; } catch(NumberFormatExceptionnfe) { return true; } } publicbooleanvalidacion(String datoEnt1, String datoEnt2 ) { boolean band=false; if (esVacio(datoEnt1)) { JOptionPane.showMessageDialog(null,"Dejo vacio el dato 1","Dejo vacio el dato",JOptionPane.ERROR_MESSAGE); band=true; } else if (NoEsNumerico(datoEnt1)) { JOptionPane.showMessageDialog(null,"El dato 1 debe ser un Numero entero","Dato incorrecto",JOptionPane.ERROR_MESSAGE); band=true; } if (esVacio(datoEnt2)) { JOptionPane.showMessageDialog(null,"Dejo vacio el dato 2","Dejo vacio el dato",JOptionPane.ERROR_MESSAGE);

band=true; } else if (NoEsNumerico(datoEnt2)) { JOptionPane.showMessageDialog(null,"El dato 2 debe ser un Numero entero","Dato incorrecto",JOptionPane.ERROR_MESSAGE); band=true; } return band; } public void actionPerformed(ActionEvent e){ if(e. getSource()==botonAceptar) { if (validacion(campoTxt.getText(),campoTxt2.getText())==false) { double x=Double.parseDouble(campoTxt.getText()); double y=Double.parseDouble(campoTxt2.getText()); suma=(x+y); total.setText("Resultado = " + suma); setTitle("El resultado de la suma es"); } } if (e. getSource()==botonLimpiar) { campoTxt.setText(""); campoTxt2.setText(""); total.setText("Resultado ="); setTitle(""); } } public static void main(String[] ar){ Entradas2 form=new Entradas2(); form.setBounds(0,0,320,180); form.setVisible(true); form.setResizable(false); form.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 : ESMERALDA BAXIN PUCHETA

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 MiniCaculadora.java

importjavax.swing.*; importjava.awt.event.*; importjavax.swing.JOptionPane;

public class MiniCal extends JFrame implements ActionListener {

privateJTextField campo1Txt, campo2Txt; privateJLabel etiqueta1,etiqueta2, resultado; privateJButtonbotonSuma, botonResta, botonMultiplicacion, botonDividir, botonLimpiar; doubleoperacion=0;

publicMiniCal() { setLayout(null); etiqueta1=new JLabel(" Dato1: "); etiqueta1.setBounds(10,30,100,30); add(etiqueta1);

campo1Txt=new JTextField(); campo1Txt.setBounds(120,40,140,20); add(campo1Txt);

setLayout(null); etiqueta2=new JLabel(" Dato2: "); etiqueta2.setBounds(10,80,100,30);

add(etiqueta2);

campo2Txt=new JTextField(); campo2Txt.setBounds(120,74,140,20); add(campo2Txt);

setLayout(null); resultado=new JLabel("Resultado:"); resultado.setBounds(10,110,100,50); add(resultado);

botonSuma=new JButton("+"); botonSuma.setBounds(10,150,50,50); add(botonSuma); botonSuma.addActionListener(this);

botonResta=new JButton("-"); botonResta.setBounds(75,150,50,50); add(botonResta); botonResta.addActionListener(this);

botonMultiplicacion=new JButton("*"); botonMultiplicacion.setBounds(140,150,50,50); add(botonMultiplicacion); botonMultiplicacion.addActionListener(this);

botonDividir=new JButton("/");

botonDividir.setBounds(200,150,50,50); add(botonDividir); botonDividir.addActionListener(this);

botonLimpiar=new JButton("CE"); botonLimpiar.setBounds(260,150,50,50); add(botonLimpiar); botonLimpiar.addActionListener(this); } publicbooleanesVacio(String datoIn) { if(datoIn.length()==0) return (true); else return(false); } publicbooleannoEsNumerico(String datoIn) { try { Double.parseDouble(datoIn); return (false); } catch (NumberFormatExceptioner) { return true; }

} publicbooleanvalidacion(String datoIn1, String datoIn2) { boolean band=false; if(esVacio(datoIn1)) { JOptionPane.showMessageDialog(null,"Dato1 vacio", "ERROR",JOptionPane.ERROR_MESSAGE); band=true; } else if(noEsNumerico(datoIn1)) { JOptionPane.showMessageDialog(null,"Eldato 1 debesernumerico","Datoincorrecto",JOptionPane.ERROR_MESSAGE); band=true; }

if(esVacio(datoIn2)) { JOptionPane.showMessageDialog(null,"Dato2 vacio","ERROR",JOptionPane.ERROR_MESSAGE); band=true; } else if(noEsNumerico(datoIn2)) { JOptionPane.showMessageDialog(null,"Eldato 2 debesernumerico","Datoincorrecto",JOptionPane.ERROR_MESSAGE); band=true; }

return band; }

public void actionPerformed(ActionEvent a) { if(a.getSource()==botonSuma) { if(validacion(campo1Txt.getText(),campo2Txt.getText())==false)

{ double x=Double.parseDouble(campo1Txt.getText()); double y=Double.parseDouble(campo2Txt.getText()); operacion=x+y; resultado.setText("Resultado= "+operacion); setTitle("El resultado es..."); } } if(a.getSource()==botonResta) { if(validacion(campo1Txt.getText(),campo2Txt.getText())==false) {

double x=Double.parseDouble(campo1Txt.getText()); double y=Double.parseDouble(campo2Txt.getText()); operacion=x-y; resultado.setText("Resultado: "+operacion);

setTitle("El resultado es "); } } if(a.getSource()==botonMultiplicacion) { if(validacion(campo1Txt.getText(),campo2Txt.getText())==false) {

double x=Double.parseDouble(campo1Txt.getText()); double y=Double.parseDouble(campo2Txt.getText()); operacion=x*y; resultado.setText("Resultado:"+operacion); setTitle("El resultado es...."); } } if(a.getSource()==botonDividir) { if(validacion(campo1Txt.getText(),campo2Txt.getText())==false) {

double x=Double.parseDouble(campo1Txt.getText()); double y=Double.parseDouble(campo2Txt.getText()); operacion=x/y; resultado.setText("Resultado:"+operacion); setTitle("Elresultadoes "); } }

if(a.getSource()==botonLimpiar) { campo1Txt.setText(""); campo2Txt.setText(""); resultado.setText("Resultado");

setTitle(""); } }

public static void main(String []args) { MiniCalcalc=new MiniCal(); calc.setBounds(0,0,325,350); calc.setVisible(true); calc.setResizable(false); calc.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 :Esmeralda BaxinPucheta

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%

9%

PROGRAMA: CuotaHipoteca.java
import java.awt.event.ActionEvent; import javax.swing.*; import java.awt.event.*; public class CuotaHipoteca extends JFrame implements ActionListener { private JTextField campoTxt, campo2Txt, campo3Txt; private JLabel etiqueta1, etiqueta2,etiqueta3,resultado; private JButton botonAceptar, botonLimpiar; public CuotaHipoteca() { setLayout(null); etiqueta1=new JLabel("Cantidad: "); etiqueta1.setBounds(20,30,100,30); add(etiqueta1); campoTxt=new JTextField(); campoTxt.setBounds(80,30,80,20); add(campoTxt);

setLayout(null); etiqueta2=new JLabel("Aos: "); etiqueta2.setBounds(180,30,100,30); add(etiqueta2);

campo2Txt=new JTextField(); campo2Txt.setBounds(220,30,80,20); add(campo2Txt);

setLayout(null); etiqueta3=new JLabel("Interes: "); etiqueta3.setBounds(310,30,100,30); add(etiqueta3); campo3Txt=new JTextField(); campo3Txt.setBounds(370,30,80,20); add(campo3Txt); setLayout(null); resultado=new JLabel("Resultado:"); resultado.setBounds(10,150,400,30); add(resultado); botonAceptar=new JButton("Aceptar"); botonAceptar.setBounds(100,100,100,30); add(botonAceptar); botonAceptar.addActionListener(this); botonLimpiar=new JButton("Limpiar"); botonLimpiar.setBounds(220,100,100,30); add(botonLimpiar); botonLimpiar.addActionListener(this); } public void actionPerformed(ActionEvent e) { if(e.getSource()==botonAceptar) if (e.getSource()==botonLimpiar) { campoTxt.setText(""); campo2Txt.setText("");

resultado.setText("Resultado"); setTitle(""); } } public static void main(String []ar) { CuotaHipoteca form=new CuotaHipoteca(); form.setBounds(0,0,480,250); form.setVisible(true); form.setResizable(false); form.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 : ESMERALDA BAXIN PUCHETA

CARACTERSTICAS A CUMPLIR Desarrollo Emplea ActionListener Emplea JFrame y JButton en el programa Implement validacin en todos los JTextField

CUMPLE SI NO 1% 1% 10%

OBSERVACIONES

CARACTERSTICAS A CUMPLIR
Resultados:

CUMPLE SI NO

OBSERVACIONES

El programa captura errores en tiempo 10% de ejecucin y enva el mensaje correspondiente.


Responsabilidad:

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

12%

You might also like