Created
November 15, 2019 00:53
-
-
Save JesusAdson/d9c37180c82f803f64d25f39fb5dae9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package college_java; | |
import java.util.Scanner; | |
public class Cadastro_func_2 { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
System.out.print("\t\tCADASTRO DE FUNCIONARIO\t\t\n"); | |
System.out.print("Quantos funcionarios deseja cadastrar?: "); | |
int qtd = sc.nextInt(); | |
String[] nomes = new String[qtd]; | |
double[] salarios = new double[qtd]; | |
double[] horas_extras = new double[qtd]; | |
double[] valor_total_horas_extras = new double[qtd]; | |
double[] valor_hora = new double[qtd]; | |
int[] codigo = new int[qtd]; | |
double maior = 0, menor = 999; | |
double media_a_receber = 0, media = 0, media2 = 0; | |
String getName = "", getname = ""; | |
boolean opa = false; | |
System.out.print("\t\tInserindo dados\t\t\n"); | |
for (int i = 0; i < nomes.length; i++) { | |
System.out.println("Func. Cod. " + i); | |
codigo[i] = i; | |
System.out.print("Nome: "); | |
nomes[i] = sc.next(); | |
System.out.print("Salario: "); | |
salarios[i] = sc.nextDouble(); | |
System.out.print("Horas extras: "); | |
horas_extras[i] = sc.nextDouble(); | |
System.out.print("\n"); | |
} | |
for (int i = 0; i < nomes.length; i++) { | |
valor_hora[i] = (salarios[i] / 220) * 1.5; | |
valor_total_horas_extras[i] = valor_hora[i] * horas_extras[i]; | |
media_a_receber = (media_a_receber + valor_total_horas_extras[i]) / nomes.length; | |
media = (media + horas_extras[i]); | |
media2 = media / nomes.length; | |
if(valor_total_horas_extras[i] > maior){ | |
maior = valor_total_horas_extras[i]; | |
getName = nomes[i]; | |
} | |
if(valor_total_horas_extras[i] < menor){ | |
menor = valor_total_horas_extras[i]; | |
getname = nomes[i]; | |
} | |
if(menor == maior){ | |
opa = true; | |
} | |
} | |
System.out.print("\t\tMENU\t\t\n"); | |
System.out.print("[1] -- BUSCAR FUNCIONARIO POR CODIGO" | |
+ "\n[2] -- BUSCAR FUNCIONARIO POR NOME" | |
+ "\n[3] -- LISTAR TUDO" | |
+ "\n[4] -- SAIR " | |
+ "\nSua opcao: "); | |
int opc = sc.nextInt(); | |
switch (opc) { | |
case 1: | |
boolean v_f = true; | |
do { | |
System.out.print("Codigo: "); | |
int cod = sc.nextInt(); | |
for (int i = 0; i < nomes.length; i++) { | |
if (cod == codigo[i]) { | |
v_f = true; | |
System.out.print("Nome: " + nomes[i] + "\nSalario: " + salarios[i] | |
+ "\nTotal de horas extras: " + horas_extras[i]); | |
System.out.printf("\nValor da hora extra:%.2f ", valor_total_horas_extras[i]); | |
System.out.printf("\nSalario com hora extra:%.2f ", (salarios[i] + valor_total_horas_extras[i])); | |
} else { | |
System.out.println("Codigo nao encontrado!"); | |
v_f = false; | |
} | |
} | |
} while (v_f == false); | |
break; | |
case 2: | |
v_f = true; | |
do { | |
System.out.print("Nome: "); | |
String nome = sc.next(); | |
for (int i = 0; i < nomes.length; i++) { | |
if (nomes[i].equals(nome)) { | |
v_f = true; | |
System.out.print("Nome: " + nomes[i] + "\nSalario: " + salarios[i] | |
+ "\nTotal de horas extras: " + horas_extras[i]); | |
System.out.printf("\nValor da hora extra:%.2f ", valor_total_horas_extras[i]); | |
System.out.printf("\nSalario com hora extra:%.2f ", (salarios[i] + valor_total_horas_extras[i])); | |
} | |
if(nomes[i].equals(nome) == false){ | |
System.out.print("Nome nao encontrado!\n"); | |
v_f = false; | |
} | |
} | |
} while (v_f == false); | |
break; | |
case 3: | |
System.out.print("Listando funcionarios!!\n\n"); | |
for(int i = 0; i < nomes.length; i++){ | |
System.out.print("Nome: " + nomes[i] + "\nSalario: " + salarios[i] + | |
"\nTotal de horas extras: " + horas_extras[i]); | |
System.out.printf("\nValor da hora extra:%.2f ", valor_total_horas_extras[i]); | |
System.out.printf("\nSalario com hora extra:%.2f ", (salarios[i] + valor_total_horas_extras[i])); | |
System.out.print("\n\n"); | |
} | |
System.out.printf("\n\t\tALGUMA COISA AQUI\t\t\n\nMedia das horas extras: " + media2 +"\nMedia do valor a receber: R$%.2f ", media_a_receber); | |
if(opa == false){ | |
System.out.print("\nFunc. com maior valor: " + getName + "\nFunc. com menor valor: " + getname); | |
} | |
if(opa == true){ | |
System.out.print("\nFuncionarios recebem o mesmo salario!"); | |
} | |
break; | |
case 4: | |
System.out.print("\nFinalizando..." | |
+ "\n..." | |
+ "\n.." | |
+ "\n." | |
+ "\nPrograma finalizado!"); | |
} | |
sc.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment