我一直收到错误消息"retailPrice cannot be resolved to a variable"
。我也在其他几条线上也得到了,但让我们从这里开始。
import java.text.DecimalFormat;
class Billing
{
public static void main(String[] args)
{
computeBill(19.99);
computeBill(19.99, 3);
computeBill(19.99, 3, .20);
computeBill(19.99, 3, .20, .10);
}
public static void computeBill(double book)
{
DecimalFormat f = new DecimalFormat("0.00");
double retialPrice = (book * .085) + book;
String total = (f.format(retailPrice));
System.out.println("The photo book after tax is $" + total);
}
答案 0 :(得分:0)
您拼写了变量名。看到线:
double retialPrice = (book * .085) + book;
您声明它的拼写错误为retialPrice
,然后在下一行中引用它正确地拼写为retailPrice
。