需要幫助來計算兩種不同工資級別的工資!錯誤是淨總數不正確。謝謝所有他們是非常有益的意見和現在的作品:)我希望我的這部分代碼可以幫助其他初學者學習使用循環和if語句:幾乎在那裏,只需要在這個工資計算中向正確的方向推一點點?
public static void main(String[]args)
{
Scanner input = new Scanner (System.in);
DecimalFormat Currency = new DecimalFormat("###,###,##0.00");
double normHrs = 0, overHrs = 0, bonusHrs = 0, actualHrs = 0, normPay = 0, overPay =0, bonusPay = 0, grossWage = 0,vat23 = 0, netWage =0;
String empName, nextEMP = "y";
System.out.println ("************************");
System.out.println ("HUMAN RESOURCES: PAYROLL"); //
System.out.println ("************************");
while (nextEMP.equalsIgnoreCase("y"))
{
System.out.print("Please enter an employee's first name: ");
empName = input.next();
System.out.print("Please enter their total hours worked: ");
actualHrs = input.nextDouble();
if (actualHrs <=36)
{
normHrs=actualHrs;
}
else
{
normHrs = 36;
bonusHrs = actualHrs - 50;
overHrs = actualHrs -36;
}
if ("bob".equalsIgnoreCase(empName))
{
bonusPay = bonusHrs > 0 ? bonusHrs : 0;
normPay = normHrs * 8; // £8 x 36 hours
overPay = overHrs * 12; // £12 x 36+ hours
}
else
{
bonusPay = bonusHrs >0 ? 20 : 0;
normPay = normHrs * 5.75;
overPay = overHrs * 9.25;
}
}
我會穿越後這https://codereview.stackexchange.com/以獲得更好的佈局驗證碼出來,使之更具可讀性過的一些技巧。 –
看起來該熟悉使用調試器了。 –
我只是一個初學者,並遵循導師設置的指示。我們必須在提高代碼效率之前保持基礎知識,但是要感謝您的提示:) – user3058983