import javax.swing.JOptionPane;
public class PayCheckStatic
{
public static void main(String[] args)
{
while (name!=null)
{
String name = JOptionPane.showInputDialog("Please enter the next employees name");
String wage = JOptionPane.showInputDialog("Please enter their hourly wage?");
String hoursWorked = JOptionPane.showInputDialog ("How many hours did they work this last work?");
double wages = Double.parseDouble(wage);
double hours = Double.parseDouble(hoursWorked);
calculatePay(name,wages,hours);
}
}
private static void calculatePay(String name,double wages,double hours)
{
if (hours > 40)
{
double pay = ((wages * 40)+((hours - 40)*(1.5 * wages)));
JOptionPane.ShowMessageDialog (null,name + "'s pay is £" + pay);
}
else
{
double pay = (wages * hours);
JOptionPane.ShowMessageDialog (null,name + "'s pay is £" + pay);
}
}
}
由於某種原因,我的代碼將無法編譯,它提出找不到符號錯誤,我不能找出原因。錯誤顯示3次,其中2個顯示在消息對話框中。有關如何修復它的任何提示?Java - 薪水問題
哪些線造成的錯誤?你能顯示確切的錯誤信息嗎?這些都是您和我們幫助尋找解決方案的關鍵。雖然這次您可能會得到一個解決方案,但下次您提出有關錯誤(或任何內容)的問題時,請包含所有相關信息。 –