Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package empresa;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class Empresa {
- public static void main(String[] args) throws FileNotFoundException {
- Scanner leia = new Scanner(System.in);
- Funcionario func[] = new Funcionario[10];
- lerdados(func);
- int opcao = 0;
- while (opcao != 3) {
- System.out.printf("\nControle de salários\n");
- System.out.printf("1 – Salários finais\n");
- System.out.printf("2 – Pesquisa salário por filial\n");
- System.out.println("3 – Sair");
- System.out.println("Digite a opção");
- opcao = leia.nextInt();
- switch (opcao) {
- case 1:
- System.out.println("");
- salario_Final(func);
- System.out.println("");
- System.out.println("Valor total da folha de pagamento: " + pagamentoTotal_Empresa(func));
- break;
- case 2:
- System.out.println("Digite a Filial");
- char cod = leia.next().charAt(0);
- if (cod == 'a' || cod == 'b' || cod == 'c') {
- System.out.println("");
- System.out.println("O Menor salario da Filial é do " + func[menorSalario_Filial(func, cod)].getNome() + " " + func[menorSalario_Filial(func, cod)].getSalbase());
- } else {
- System.out.println("Filial não encontrada");
- }
- break;
- case 3:
- System.out.println("Sair");
- break;
- default:
- System.out.println("Opcão Invalida");
- break;
- }
- }
- }
- public static void lerdados(Funcionario func[]) throws FileNotFoundException {
- File arq = new File("dados.txt");
- Scanner leiaArq = new Scanner(arq);
- System.out.printf("%15s %15s %15s\n", leiaArq.next(), leiaArq.next(), leiaArq.next());
- for (int i = 0; i < 10; i++) {
- func[i] = new Funcionario(leiaArq.next(), leiaArq.next().charAt(0), leiaArq.nextDouble());
- System.out.printf("%9s %15c %20.2f\n", func[i].getNome(), func[i].getCodFilial(), func[i].getSalbase());
- }
- }
- public static void salario_Final(Funcionario func[]) {
- System.out.printf("%10s %10s\n", "Nome", "Salário Final");
- for (int i = 0; i < 10; i++) {
- System.out.printf("%10s %10.2f\n", func[i].getNome(), func[i].calcSalFinal());
- }
- }
- public static double pagamentoTotal_Empresa(Funcionario func[]) {
- double soma = 0;
- for (int i = 0; i < 10; i++) {
- soma = soma + func[i].calcSalFinal();
- }
- return soma;
- }
- public static int menorSalario_Filial(Funcionario func[], char cod) {
- int ind = 0;
- double salario = 0;
- int cont = 0;
- for (int i = 0; i < 10; i++) {
- if (cod == func[i].getCodFilial()) {
- if (cont == 0) {
- ind = i;
- salario = func[i].getSalbase();
- cont++;
- } else {
- if (salario > func[i].getSalbase()) {
- ind = i;
- salario = func[i].getSalbase();
- cont++;
- }
- }
- }
- }
- return ind;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement