面向对象编程..我的主要方法有问题,它说找不到符号。为什么?
在这部分:
double grossPay = payroll.getHoursWorked * payroll.getPayRate * payroll.getTaxRate ;
我所知道的是我已经在这里的基类中声明了它:
public class Exercise1 {
private long hoursWorked;
private double payRate;
private double taxRate;
public void setHoursWorked(long temp){
hoursWorked = temp;
}
public void setPayRate (double temp){
payRate = temp;
}
public void setTaxRate (double temp){
taxRate = temp;
}
public double getTaxRate (){
return(taxRate);
}
public double getPayRate (){
return(payRate);
}
public double getHoursWorked (){
return(hoursWorked);
}
}
这是我的主要课程:
public class payroll{
public static void main(String args[]){
Exercise1 payroll = new Exercise1();
payroll.setHoursWorked(28);
payroll.setPayRate (120.00);
payroll.setTaxRate (0.30);
double grossPay = payroll.getHoursWorked * payroll.getPayRate * payroll.getTaxRate;
System.out.println("Gross pay is:"+ grossPay);
}
}
为什么一直问“找不到符号”?请帮忙..我是编程新手:(