Compiler errors 餐厅计费程序连续出错

Compiler errors 餐厅计费程序连续出错,compiler-errors,Compiler Errors,我一次又一次地犯这个错误 import java.util.Scanner; //This program computes tax and tip on a restaurant bill. public class RestaurantBill { public static void main(String[] args) { double charge; double tax = 0.0675; double tipRate = 0.15; do

我一次又一次地犯这个错误

 import java.util.Scanner;
//This program computes tax and tip on a restaurant bill.

public class RestaurantBill
{
   public static void main(String[] args)   {


   double charge;
   double tax = 0.0675;
   double tipRate = 0.15;
   double totalWithTax;
   double taxAmount;
   double tipAmount;
   double grandTotal;


   Scanner keyboard = new Scanner(System.in);
   System.out.print("What is your name? ");
   name = keyboard.nextLine();
   System.out.print("Please enter the cost of your meal ");
   charge = keyboard.nextDouble();

   System.out.println("Hi there " + name "\n Your tax                                        is "                            +                        taxAmount "     \n     Your tip will be $" + tipAmount " /n and your total cost will be $" + grandTotal);
   }
}

字符串连接中的语法错误:在错误消息中指示的行中,在name之后、taxAmount之后和tipAmount之后添加+

或者将该行拆分为多个单独的打印:

  RestaurantBill2.java:24: error: ')' expected
  System.out.println("Hi there " + name "\n Your tax is " + taxAmount " \n Your tip will be $" + tipAmount " /n and your total cost will be $" + grandTotal);
检查使用后缀为…ln的函数时是否确实需要打印\n

您可能还想用\n替换/n并清理一些空间。
你当然也需要添加一些税收和小费计算…

是的,当我将代码转移到这个站点时,额外的空格添加了自己…不知道为什么会发生这样的情况…但我重新编写了整个过程…现在我得到了一个未初始化的变量错误…这似乎值得一个单独的问题。
System.out.println("Hi there " + name);
System.out.println("\n Your tax is " + taxAmount);
System.out.println("\n Your tip will be $" + tipAmount);
System.out.println("/n and your total cost will be $" + grandTotal);