Answer to Question #273877 in Java | JSP | JSF for Zaid

Question #273877

A company dealing with marketing wants to manage the data of its employees. Each employee has a full name, unique employee number (2019000 to 2019999) and the number of hours he worked and her hourly wage (price).




1
Expert's answer
2021-12-02T00:35:55-0500
import java.util.Scanner;


public class Main {
    public static double calSal(int Hr, double HrWage) {
        return HrWage * Hr;
    }


    public static double calcAve(double[] Sal) {
        return calAmount(Sal) / Sal.length;
    }


    public static double calAmount(double[] Sal) {
        double sum = 0;
        for (double salary : Sal) {
            sum += salary;
        }
        return sum;
    }


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the number of employees:");
        int n = Integer.parseInt(in.nextLine());
        String[] names = new String[n];
        int[] Enums = new int[n];
        int[] numHr = new int[n];
        double[] hourlyWages = new double[n];
        double[] Sal = new double[n];
        for (int i = 0; i < n; i++) {
            System.out.println("Name:");
            names[i] = in.nextLine();
            System.out.println("Employee number:");
            Enums[i] = Integer.parseInt(in.nextLine());
            System.out.println("Number of hours:");
            numHr[i] = Integer.parseInt(in.nextLine());
            System.out.println("Hourly wage:");
            hourlyWages[i] = Double.parseDouble(in.nextLine());
            Sal[i] = calSal(numHr[i], hourlyWages[i]);
        }
        for (int i = 0; i < n; i++) {
            System.out.println(names[i] + " " + Enums[i] +
            " " + numHr[i] +
                    "h " + hourlyWages[i] + "$/h " + Sal[i] + "$");
        }


        System.out.println("Average: " + calcAve(Sal) + 
        " Total: " + calAmount(Sal));
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS