如何解决问题以匹配 Java 中的预期输出?

How to solve a problem to match the expected output in Java?

不含税和小费的餐费为12.00,餐费税率为20%,餐费小费为8%。 您需要使用扫描仪 class 来接收用户的输入。

12.00
20
8

预期输出为:

15

我尝试了不同的方法,尤其是下面的代码,但我得到了不同的结果。我无法像预期的那样得到 15。

enter public class MealSolution {

private static final Scanner scanner = new Scanner(System.in);

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here
    
       System.out.print("Enter cost of meal: ");
       double meal_cost = scanner.nextDouble();

       System.out.print("Enter the tip percent: ");
       int tip_percent = scanner.nextInt();

       System.out.print("Enter tax of meal: ");
       int tax_percent = scanner.nextInt();

       double  tip = meal_cost * tip_percent/100;
       double  tax = meal_cost * tax_percent/100;
       double  cost = meal_cost + tip + tax;
       long total_cost = Math.round(cost);
       System.out.println(total_cost);
    
       scanner.close();
    }
}

要获得总费用,请计算餐费和加上小费和税费。

   double  cost = meal_cost + tip + tax;