使用扫描仪......错误:'.class'预期

时间:2013-10-06 17:22:44

标签: java

getDiscountedBill()将返回账单的最终金额 如果账单大于2000,账单将获得15%的折扣

public class Discount
{
private double bill;
private double discount;
private double amt;

public static double getDiscountedBill(double bill)
{
    if (bill > 2000)
    {
        discount = bill * .15; 
        amt = bill - discount; 
    }

    return amt;

    if (bill <= 2000)
    {
        return bill;
    }
}

public void print()
{
    System.out.println("Bill after discount :: ");
    System.out.printf("%.2f\n", amt);
}

另一个主要代码

    public static void main( String args[] )
{
    Scanner keyboard = new Scanner(System.in);


    out.print("Enter the original bill amount :: ");
    double amt = keyboard.nextDouble();

    keyboard.getDiscountedBill(double);
    keyboard.print();

错误消息:错误:'。class'预期         keyboard.getDiscountedBill(双);

1 个答案:

答案 0 :(得分:2)

更改此声明:

keyboard.getDiscountedBill(double);

这一个:

double discuontedBill = getDiscountedBill(amt);

您应该传递值作为方法参数,而不是传递类型