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);
            }
        });
    }

 

PRECIO BASE ,CALCULAR INSTALACION, FORMACION, ALIMENTACION

public class Ejercicio2 extends javax.swing.JFrame {

    /** Creates new form Ejercicio2 */
    public Ejercicio2() {
  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add yprivateour handling code here:
        double precio_base, precio_install, precio_for, precio_ali;
        precio_base =Double.parseDouble(etipreciobase.getText());
        precio_install =Double.parseDouble(etiprecioInstalacion.getText());
        precio_for =Double.parseDouble(etiprecioFormacion.getText());
        precio_ali =Double.parseDouble(etiprecioAlimentacion.getText());
    double precio_total;
    precio_total=precio_base;
        if (ttbtnInstalacion.isSelected()){
            precio_total=precio_total+precio_install;
        }
        if (ttbtnFormacion.isSelected()){
            precio_total=precio_total+precio_for;
        }
        if (ttbtnAlimentacion.isSelected()){
            precio_total=precio_total+precio_ali;
        }
    etiTotal.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 Ejercicio2().setVisible(true);
            }
        });
    }

PROFORMA PARA VENDER PRODUCTOS CON JCOMBOX

public class ejercicio1 extends javax.swing.JFrame {
private void jcbotecladoActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        int entrada =(this.jcboteclado.getSelectedIndex());
        switch (entrada){
            case 0: jtxtp2.setText("25");break;
            case 1: jtxtp2.setText("70");break;
        }
    }                                          

    private void jcbomonitorActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
        int entrada =(this.jcbomonitor.getSelectedIndex());
        switch (entrada){
            case 0: jtxtp1.setText("600");break;
            case 1: jtxtp1.setText("1300");break;
        }
    }                                          

    private void jcbocpuActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        int entrada =(this.jcbocpu.getSelectedIndex());
        switch (entrada){
            case 0: jtxtp3.setText("600");break;
            case 1: jtxtp3.setText("800");break;
        }
    }                                      

    private void jcbomouseActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        int entrada =(this.jcbomouse.getSelectedIndex());
        switch (entrada){
            case 0: jtxtp4.setText("30");break;
            case 1: jtxtp4.setText("60");break;
        }
    }                                        

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        String e=this.jtxtp1.getText();
            int p1=Integer.parseInt(e);
        e=this.jtxtc1.getText();
            int c1=Integer.parseInt(e);
        int imp1=(p1*c1);
        this.jtxtimp1.setText(""+imp1);
        e=this.jtxtp2.getText();
            int p2=Integer.parseInt(e);
        e=this.jtxtc2.getText();
            int c2=Integer.parseInt(e);
        int imp2=(p2*c2);
        this.jtxtimp2.setText(""+imp2);
        e=this.jtxtp3.getText();
            int p3=Integer.parseInt(e);
        e=this.jtxtc3.getText();
            int c3=Integer.parseInt(e);
        int imp3=(p3*c3);
        this.jtxtimp3.setText(""+imp3);
        e=this.jtxtp4.getText();
            int p4=Integer.parseInt(e);
        e=this.jtxtc4.getText();
            int c4=Integer.parseInt(e);
        int imp4=(p4*c4);
        this.jtxtimp4.setText(""+imp4);
        int st=(imp1+imp2+imp3+imp4);
        this.jtxtST.setText(""+st);
        double igv=(st*0.18);
        this.jtxtigv.setText(""+igv);
        double neto=(st+igv);
        this.jtxtn.setText(""+neto);
    }                                       

    /**
    * @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);
            }
        });
    } 

miércoles, 25 de mayo de 2011

Calcular el sueldo de un empleado en Jframe

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                       
        String entrada=this.jTextField1.getText();
        double pph=Double.parseDouble(entrada);
        entrada = this.jTextField2.getText();
        double ht=Double.parseDouble(entrada);
        double aum=0,sn=0;
        double sb=ht*pph;
        String regalo = null;
        if(sb>=200 && sb<=500)
        {aum=sb*0.03;
         regalo="Un Polo";
        }
        if (sb>=501 && sb<=1000)
            {aum=sb*0.05;
         regalo="memoria USB 8GB";
        }
        if (sb>1000)
        {aum=sb*0.08;
         regalo="Celular Multimedia";
        }
        sn=sb+aum;
        this.jTextField3.setText(""+sb);
        this.jTextField4.setText(""+aum);
        this.jTextField5.setText(""+regalo);
        this.jTextField6.setText(""+sn);
    }                                        

Calcular el sueldo de un empleado en soles ,dolares y euros

public class ejemplo2 extends javax.swing.JFrame {

    /** Creates new form ejemplo2 */
    public ejemplo2() {
        initComponents();
    }

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                       
      String entrada=this.jTextField1.getText();
      int sueldo=Integer.parseInt(entrada);
      double dolares=sueldo/2.81;
      double euros=sueldo/4.05;
      this.jTextField2.setText(""+dolares);
      this.jTextField3.setText(""+euros);
    }

Robot, ingresar el (codigo,nombre,velocidad.movimiento, desplazamiento)

import javax.swing.JOptionPane;

public class Main{

  public static void main(String[] args) {
     String x=JOptionPane.showInputDialog("Ingrese codigo de robot");
     int cod=Integer.parseInt(x);
     String nombre=JOptionPane.showInputDialog("Ingrese el nombre del robot");
     String v=JOptionPane.showInputDialog("Ingrese la velocidad del robot");
     int velocidad=Integer.parseInt(v);
      x=JOptionPane.showInputDialog("Ingrese el numero de la opcion:(1:brazos/2:movimientos)");
     int op=Integer.parseInt(x);
     if (op==1){
       String Y=JOptionPane.showInputDialog("Elegir 1:derecha/ 2:izquierda/ 3:desplazamiento");
       int op1=Integer.parseInt(Y);
       if (op1==1)
        {
        String d=Funcionderecha(op1);
        JOptionPane.showMessageDialog(null,"El robort se movio:"+d);
        }
       else
           if(op1==2)
           {
           String i=Funcionizquierda(op1);
           JOptionPane.showMessageDialog(null,"El robot se movio:"+i);
           }
      else
          if(op1==3)
          {
          String A=FuncionA(op1);
          JOptionPane.showMessageDialog(null,"El robot se mueve:"+A);
          }
      else
          {
           JOptionPane.showMessageDialog(null,"Error de la opcion(solo1/2/3)");
          }
      }
     else if(op==2)
          {
           String B=JOptionPane.showInputDialog("Ingrese velocidad de desplazamiento:");
           Double velo=Double.parseDouble(B);
           Double velodespla=Funciondesplazamiento(velocidad,velo);
           JOptionPane.showMessageDialog(null,"El robot se desplaza a una velocidad:"+ velodespla);
          }
     }


   public static String Funcionderecha(int op1)
       {
       String mensa="";
         if (op1 == 1)
               {
              mensa ="derecha";
               }
         else
               {
               JOptionPane.showMessageDialog(null,"Error");
               }
         return (mensa);
        }


   public static String Funcionizquierda(int op1)
        {
         String mensa="";
           if(op1==2)
               {
                mensa="izquierda";
               }
           else
              {
               JOptionPane.showMessageDialog(null,"Error");
              }
           return (mensa);
         }

     public static String FuncionA(int op1)
        {
         String mensa="";
           if(op1==3)
               {
                mensa ="ambos brazos";
               }
           else
              {
               JOptionPane.showMessageDialog(null,"Error");
              }
           return (mensa);
         }


     public static double Funciondesplazamiento (double velo, double velodespla)
        {
           double velocidad;
           velocidad= velo+velodespla;
           return(velocidad);
        }

  }

miércoles, 18 de mayo de 2011

PROGRAMA QUE PERMITE SELECCIONAR LOS ANIMALES



 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        String mensaje="animales elegidos:  ";
        if (this.jCheckBox1.isSelected()){
            mensaje=mensaje+"Perro, ";
        }
        if (this.jCheckBox2.isSelected()){
            mensaje=mensaje+"Gato, ";
         }

        if (this.jCheckBox3.isSelected()){
            mensaje=mensaje+"raton";
        }
       this.jLabel2.setText (mensaje);{
          
       }

    }