domingo, 29 de mayo de 2011

INGRESAR LA MARCA DEL PRODUCTO (SANSUNG,LG) Y SE MOSTRARA EL PRECIO

public class prueba extends javax.swing.JFrame {

    /** Creates new form prueba */
    public prueba() {
        initComponents();
    }
 private void jcbotecladoActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        int entrada =(this.jcboteclado.getSelectedIndex());
        switch (entrada){
            case 0: jtxtp1.setText("600");break;
            case 1: jtxtp1.setText("1300");break;
        }
    }                                          

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new prueba().setVisible(true);
            }
        });
    }

CALCULAR EL SUELDO SEGUN LAS CONDICIONES

public class Ejercicio2 extends javax.swing.JFrame {

    /** Creates new form Ejercicio2 */
    public Ejercicio2() {
        initComponents();
    }
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        String entrada=this.jTextField3.getText();
        int S=Integer.parseInt(entrada);
        double des;
        if(S<=1000 && S>=0){
            des=S*0.05;
            JOptionPane.showMessageDialog(null,"Descuento: "+des);
            this.jTextField4.setText(""+des);
            this.jTextField5.setText(""+(S-des));
        }
        else{
            des=S*0.07;
            JOptionPane.showMessageDialog(null,"Descuento: "+des);
            this.jTextField4.setText(""+des);
            this.jTextField5.setText(""+(S-des));
        }

    }                                       

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Ejercicio2().setVisible(true);
            }
        });
    }

CALCULAR EL PRECIO, EL BRUTO Y EL REGALO

public class Ejercicio1 extends javax.swing.JFrame {

    /** Creates new form Ejercicio1 */
    public Ejercicio1() {
        initComponents();
    }
  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        // TODO add your handling code here:
        String entrada=this.jTextField1.getText();
        int N1=Integer.parseInt(entrada);
         entrada=this.jTextField2.getText();
        int N2=Integer.parseInt(entrada); 
        double bruto=N1*N2;
        String regalo;
        double aum;
        if(bruto>=200 && bruto<=500){
            aum=bruto*0.03;
            regalo="Polo";
        }
        else if(bruto>=501 && bruto<=1000){
            aum=bruto*0.05;
            regalo="Memoria usb 8 GB";           
        }
        else if(bruto>=0 && bruto<=199){
         aum=0;
         regalo="Nada";
        }
        else{
            aum=bruto*0.08;
            regalo="calculadora Multimedia";
        }
        this.jTextField3.setText(""+bruto);
        this.jTextField4.setText(""+(bruto+aum)+regalo);
    }                                       

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Ejercicio1().setVisible(true);
            }
        });
    }

SELECCIONAR UN COLOR Y MOSTRARA EL COLOR ELEGIDO

public class NewJFrame extends javax.swing.JFrame {

    /** Creates new form NewJFrame */
    public NewJFrame() {
        initComponents();
        optrojo.setSelected(true);
    }
   private void optverdeActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
    }                                       

    private void optrojoActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:

    }                                      

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        String mensaje="  Color elegido: ";

        if (optrojo.isSelected()) {
            mensaje=mensaje+"Rojo";
        } else if (optverde.isSelected()) {
            mensaje=mensaje+"Verde";
        } else if (optazul.isSelected()) {
            mensaje=mensaje+"Azul";
        }

        this.jLabel1.setText(mensaje);

    }                                       

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }

PAGO AL TRABAJADOR DE LAS HORAS TRABAJADAS POR DIA

public class sliders2 extends javax.swing.JFrame {

    /** Creates new form sliders2 */
    public sliders2() {
        initComponents();
    }
 private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {                                     
        // TODO add your handling code here:
        jtxtr.setText("el valor es:"+jSlider1.getValue());
    }                                    

    private void jbtncalcularActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
        String entrada=this.jtxtprecio.getText();
        int precio=Integer.parseInt(entrada);
        double r=(precio * this.jSlider1.getValue());
        jtxttp.setText("" + r);

    }                                           

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new sliders2().setVisible(true);
            }
        });
    }

PRIMER EJERCICIO DE SLIDER

public class JFRAME1 extends javax.swing.JFrame {

    /** Creates new form JFRAME1 */
    public JFRAME1() {
        initComponents();
    }
 private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {                                     
        // TODO add your handling code here:
        etivalor.setText("el valoe es:" + jSlider1.getValue());
    }                                     

CALCULAR EL SUELDO DE UN EMPLEADO(ALIMENTO POR MES Y REITERO DE JUNIO)TAMBIEN DESCUENTO XMES

public class ejercicio3 extends javax.swing.JFrame {

    /** Creates new form ejercicio3 */
    public ejercicio3() {
        initComponents()
;
    }
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
                double base, a1, a2, a3;
        base =Double.parseDouble(jtxtse.getText());
    double precio_total;
    precio_total=base;
        if (ttbtna1.isSelected()){

            precio_total=precio_total+(base*0.04);
        }
        if (ttbtna2.isSelected()){
            precio_total=precio_total+(base*0.07);
        }
        if (ttbtnd1.isSelected()){
            precio_total=precio_total-120;
        }
    jtxttn.setText("S/."+precio_total);
    }                                       

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ejercicio3().setVisible(true);
            }
        });
    }