cesarnascimento

questao empregados poo

Feb 26th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. package questaoEmpregados;
  2.  
  3. public class Empregados {
  4. private String nome[] = new String[5];
  5. private String funcao[] = new String[5];
  6. private double acrescimo[] = new double[5];
  7. private double salario[] = new double[5];
  8.  
  9.  
  10.     public String[] getNome() {
  11.         return nome;
  12.     }
  13.  
  14.     public void setNome(String[] nome) {
  15.         this.nome = nome;
  16.     }
  17.  
  18.     public String[] getFuncao() {
  19.         return funcao;
  20.     }
  21.  
  22.     public void setFuncao(String[] funcao) {
  23.         this.funcao = funcao;
  24.     }
  25.  
  26.     public double[] getAcrescimo() {
  27.         return acrescimo;
  28.     }
  29.  
  30.     public void setAcrescimo(double[] acrescimo) {
  31.         this.acrescimo = acrescimo;
  32.     }
  33.  
  34.     public double[] getSalario() {
  35.         return salario;
  36.     }
  37.  
  38.     public void setSalario(double[] salario) {
  39.         this.salario = salario;
  40.     }
  41.  
  42.  
  43.  
  44.  
  45.  
  46. public void dados(){
  47.     nome[0] = "nome1";
  48.     nome[1] = "nome2";
  49.     nome[2] = "nome3";
  50.     nome[3] = "nome4";
  51.     nome[4] = "nome5";
  52.  
  53.     funcao[0] = "funcao1";
  54.     funcao[1] = "funcao2";
  55.     funcao[2] = "funcao3";
  56.     funcao[3] = "funcao4";
  57.     funcao[4] = "funcao5";
  58.  
  59.     salario[0] = 5000;
  60.     salario[1] = 1000;
  61.     salario[2] = 3000;
  62.     salario[3] = 3005;
  63.     salario[4] = 5130;
  64.  
  65.         for(int i = 0; i< funcao.length; i++){
  66.             if(funcao[i].equals("funcao1")){
  67.                 acrescimo[i] = salario[i] * 1.10;
  68.             }
  69.             else if(funcao[i].equals("funcao2")){
  70.                 acrescimo[i] = salario[i] * 1.05;
  71.             }
  72.             else if(funcao[i].equals("funcao3")){
  73.                 acrescimo[i] = salario[i] * 1.15;
  74.             }
  75.             else if(funcao[i].equals("funcao4")){
  76.                 acrescimo[i] = salario[i] * 1.20;
  77.             }
  78.             else if(funcao[i].equals("funcao5")){
  79.                 acrescimo[i] = salario[i] * 1.35;
  80.             }
  81.         }
  82.  
  83.     for(int i = 0; i < 5; i++){
  84.         System.out.println("Empregado de nome: "+nome[i]+" com função "+funcao[i]+" e salário de: "+salario[i]+". Seu salário com acrescimo é: "+acrescimo[i]);
  85.     }
  86.  
  87. }
  88.  
  89.  
  90.  
  91. }
  92.  
  93.  
  94. //main
  95.  
  96. package questaoEmpregados;
  97.  
  98. public class EmpregadosTeste {
  99.     public static void main(String[] args) {
  100.         Empregados empregados = new Empregados();
  101.  
  102.         empregados.dados();
  103.     }
  104. }
Add Comment
Please, Sign In to add comment