問題是要創建一個程序,要求用戶輸入多少名員工。然後,每個員工都會輸入姓名,小時工資率,工作小時數。計算員工工資,加班費和總工資的結果。工資單:添加多個數組值
我的兩難困境是如何找到所有支付的總額。所有員工支付,所有員工加班費和所有員工全部支付
ex。用戶輸入:2名員工(創建兩個陣列) 將輸入兩個輸入(名稱,費率,工作小時數)
兩個結果(工資,加班費,總工資)將被計算 您如何加上支付,加班費兩名員工的支付和全額支付?
這是代碼香港專業教育學院拿出,但它需要工作
進口java.util.Scanner的;
public class paycheck {
public static void main(String[] args)
{
Scanner input= new Scanner(System.in);
System.out.print("Enter number of Employees: ");
int numberOfEmp= input.nextInt();
int[] arrayList= new int[numberOfEmp];
for (int i = 0; i < arrayList.length; i++){
System.out.print("Enter Employee Name: ");
String empName= input.next();
System.out.print("Enter hourly rate: ");
int rate= input.nextInt();
System.out.print("Enter hours worked: ");
int hours=input.nextInt();
if (hours >=40)
{
double regPay= hours * rate;
double otPay = (hours-40) *(rate*1.5);
double totalPay= regPay + otPay;
System.out.print("\nEmployee name: " + empName+"\n Regular pay: " + regPay +"\n Overtime pay: " + otPay+ "\n Total pay: " + totalPay+ "\n"+ "\n");
}
else
{
double regPay= hours * rate;
double otPay =0;
double totalPay= regPay + otPay;
System.out.print("\nEmployee name: " + empName+ "\n Regular pay: " + regPay +"\n Overtime pay: " + otPay+ "\n Total pay: " + totalPay+ "\n"+ "\n");
}
}
}
}