2015-02-12 96 views
-4

我有以下代碼:爪哇 - 類預期的錯誤

import javax.sqing.JOptionPane; 
public class DebugTwo4 
{ 
    public static void main(String[] args) 
    { 
     string costString; 
     double cost; 
     final double TAX = 0.06; 
     costString = JOptionPane.showInputDialog("Enter price of item you are buying", "Purchases", JOptionPane.INFORMATION_MESSAGE); 
     cost = double.parsecost (coststring); 
     JOptionPane.showMessageDialog(null,"With " + TAX * 100 + "% tax, purchase is $" + (cost - cost * TAX)); 
    } 
} 

我收到以下錯誤:

DebugTwo4.java:11: error: class expected 
    cost = double.parsecost (coststring); 

DebugTwo4.java:11: error: ';' expected 
    cost = double.parsecost (coststring); 

請幫幫忙!

+2

將來,在您的答案中輸入您的代碼。與嘗試讀取/重新輸入屏幕截圖中的內容相比,它將使回答更加容易。 – ThreadedLemon 2015-02-12 00:21:02

+3

歡迎來到StackOverflow。請將您的代碼*發佈在問題本身中。此外,請務必清楚解釋您收到的錯誤,您嘗試解決的錯誤,以及您需要幫助的具體內容。 – 2015-02-12 00:21:03

回答

0

不知道什麼parsecost是應該做的,因爲我沒有看到它的定義任何地方,但是從我瞭解你能不能改變這一行:

cost = double.parsecost (coststring); 

爲了這樣的事情:

cost = Double.parseDouble(coststring);