0
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);
}
}
,我得到這個錯誤一遍又一遍......與餐廳的計費程序連續錯誤
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);
耶多餘的空格添加自己,當我到這個網站傳輸的代碼......不知道爲什麼會發生...但我重新寫了整個事情...現在我得到一個「變量尚未初始化」的錯誤... – none 2015-02-10 21:34:01
這似乎應該得到一個單獨的問題。 – CiaPan 2015-02-11 06:20:34