String Java类预期错误
我有以下代码:String Java类预期错误,string,String,我有以下代码: 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("E
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);
请帮忙 我不确定parsecost应该做什么,因为我在任何地方都看不到它的定义,但据我所知,您不能更改这一行:
cost = double.parsecost (coststring);
对这样的事情:
cost = Double.parseDouble(coststring);
以后,在答案中键入代码。这将使回答比试图阅读/重新键入屏幕截图中的内容容易得多。欢迎使用StackOverflow。请在问题本身中张贴您的代码。另外,一定要清楚地解释你所遇到的错误,你试图做什么来修复它,以及你具体需要什么帮助。