class WageCalculator_1 {
public static void main(String[] args) {
WagecalculatorApp WageCalculatorObject = new WagecalculatorApp();
}
private double baseRate;
private double overtimeMultiplier;
private int hours;
private int overtime;
private int overtimeHours;
private int wages;
private String multi;
Scanner keyboard = new Scanner(System.in);
public WageCalculator_1(double baseRate, int hours)
{
this(baseRate, 1.5, hours);
}
public WageCalculator_1(double baseRate, double overtimeMultiplier, int hours) {
System.out.print("Enter your base rate: ");
baseRate = keyboard.nextDouble();
WageCalculatorObject.wagecalc(baseRate);
System.out.print("Enter your hours: ");
hours = keyboard.nextInt();
WageCalculatorObject.wagecalc(hours);
System.out.print("Would you like to enter an overtime multiplier (yes/no)? ");
multi = keyboard.next();
if (hours > 40) {
System.out.print("what is the overtime multiplier? ");
overtimeMultiplier = keyboard.nextInt();
} else if (hours <= 40) {
wages = (int) (hours * baseRate);
overtimeMultiplier = 0;
} else {
wages = (int) (40 * baseRate);
overtimeHours = hours - 40;
overtime = (int) (overtimeHours * ( 1.5 * baseRate));
wages += overtime;
}
}
}
我遇到过WageCalculatorObject的问题。我试图使用它时不断给我这个错误。我一直在努力解决这个问题,不知道该怎么办。它给了我no error message。
答案 0 :(得分:1)
您没有WageCalculatorApp对象。具体来说,除非你提供更多代码,否则在初始化WageCalculatorObject对象时,你永远不会调用它,因此你调用的任何方法都不会返回任何内容(除非你没有显示WageCalculatorApp的代码)。除非您创建一个WageCalculatorApp对象,否则不能从它返回任何内容,因为它不存在。