viernes, 4 de noviembre de 2016

Datos De Un Trabajador De Una Empresa

package arrayLSimple;


import java.util.ArrayList;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
public class arrayLSimple {
      ArrayList miAL = new ArrayList();
    public static void main(String args[]){
       
        try{
 
  JFrame.setDefaultLookAndFeelDecorated(true);
  JDialog.setDefaultLookAndFeelDecorated(true);
  UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
  UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
  UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
 

 
}
catch (Exception e)
 {
  e.printStackTrace();
 }
        JFrame ventana=new JFrame();

        arrayLSimple obA = new arrayLSimple();      
        obA.menu();      
    }

    public void menu(){
        String op;
       do{
           op = JOptionPane.showInputDialog(null,"   \nDatos De Un Trabajor De Una Empresa"
                                                 + "\n 1.Ingresar Datos Del Trabajador "
                                                 + "\n 2.Desea Saber Cuantos Años Tiene El Trabajador"
                                                 + "\n 3.Deseas Saber Cuantos Años Tienes Trabajando En La Empresa"
                                                 + "\n 4.Modificar Salario?"
                                                 + "\n 5.Desea  Saber Tus Prestaciones Sociales?"
                                                 + "\n 6.Mostrar Datos Del Trabajador"
                                                 + "\n 7.Salir");
       

           switch(op){

               case "1":
                 
                       
                         String nom,apellido,sexo,sa,fn,fi;
                         
                        nom = JOptionPane.showInputDialog(null, "Ingrese sus nombres :");
                        apellido = JOptionPane.showInputDialog(null, "ingrese sus apellidos:");
                        sexo = JOptionPane.showInputDialog(null, "ingrese su sexo : ");
                        sa = JOptionPane.showInputDialog(null, "ingrese su salario: ");
                        miAL.add(nom);
                        miAL.add(apellido);
                        miAL.add(sexo);
                        miAL.add(sa);
                     
                   break;
                   case"2":
                          int año_ac, año_na;
                        año_ac = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el año actual:") );
                         año_na = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el año de nacimiento:") );
                            int edad = año_ac-año_na;
                         miAL.add(edad);
                       
                   break;
                       
                        case "3":
                            int fe_in, fe_ac;
                            fe_ac = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el año actual:") );
                           fe_in = Integer.parseInt(JOptionPane.showInputDialog("Ingrese El Año cuando ingreso a laborar:") );
                            int añs = fe_in-fe_ac;
                         miAL.add(añs);
                         break;
                     
                        case "4":
                            String b, c;
                        int indice;
                        b = JOptionPane.showInputDialog(null, " Ingrese El Salario Actual: ");
                        if(miAL.contains(b)){
                            indice = miAL.indexOf(b);
                            c = JOptionPane.showInputDialog(null, "Ingrese El Nuevo Salario: ");
                            miAL.set(indice, c);
                        }else{
                            JOptionPane.showMessageDialog(null, "No existe el salario a modificar !", "", JOptionPane.ERROR_MESSAGE);
                        }
                                               
                   break;
                           
                         
               case "5":
                   int s;
                      s= Integer.parseInt( JOptionPane.showInputDialog( "Ingrese su salario Actual :"));
                       if (s < 400000) {
                      JOptionPane.showMessageDialog(null,"salud\nvacaciones\npension\nDotacion\nCompras En Centro Comerciales\n") ;
                             }
                          if (s > 400000) {
                      JOptionPane.showMessageDialog(null,"Bancario\nauxilio de transporte\nCesantias\nPrima De Sevicios\n ") ;
                             }
                          break;
 
               case "6":
                      String Salida= "";
                       for( int i = 0 ; i  < miAL.size(); i++){
                        Salida += " "+i+" : "+miAL.get(i)+"\n";
                       }
                        JOptionPane.showMessageDialog(null, Salida);
                           break;                    
                 
                 
                    case "7":
                        System.exit(0);
                   break;
               default:
                   JOptionPane.showMessageDialog(null, "Opcion invalida !");
                   break;
                       
           }    
       }while(!op.equals("7"));
    }
}

 

0 comentarios:

Publicar un comentario