Java 错误:解析时到达文件末尾
Java Error: Reached end of file while parsing
我不断收到错误:解析时到达文件末尾。我不知道出了什么问题。我假设我必须在某处关闭一个大括号。
import javax.swing.JOptionPane;
public class Ticketpurchasingprogram
{
public static void main (String[] args)
{
string customerName = JOptionPane.showInputDialog("Enter your name");
double ticketBaseCost = 10.60;
int seatSelection = Integer.parseIn( JOption.showInputDialog("Select your seat number")); //There is an additional charge if the seat selected is between seats 56 - 306
{
{if (seatSelection == 0 && seatSelection >= 55)
{
if (seatSelection >=56 && seatSelection >= 106)
{
if (seatSelection >= 107 && seatSelection <=206)
{
if (seatSelection >= 207 && seatSelection <= 306)
{
double seatSelectionCost = 0.00;
}
double seatSelectionCost = 7.45;
}
double seatSelectionCost = 14.30;
}
double seatSelectionCost = 35.16;
}
}
}
ticketSeatCost = ticketBaseCost + seatSlectionCost;
deliveryMethod = JOptionPane.showInputDialog("Would you like your ticket emailed or shipped?");
{if (deliveryMethod = "emailed")
{
if (deliveryMethod = "shipped")
{
double convenienceFee = ticketSeatCost * 0.03;
}
double convenienceFee = ticketSeatCost * 0.01;
}
}
totalCost = ticketSeatCost + convenienceFee;
JOptionPane.showMessageDialog(null, "**Eagle Bank Arena Ticket** 'n Customer Name: " + customerName + "'n Seat Number: " + seatNumber + "'n Delivery Method: " + deliveryMethod + "'n Ticket Base Cost: " + ticketBaseCost + "'n Seat Cost: " + seatSelectionCost + "'n Convenience Fee: " + convenienceFee + String.format("'n Total Cost $%.2f", totalCost));
}
该代码中有很多错误,很难知道从哪里开始。
if (seatSelection == 0 && seatSelection >= 55)
seatSelection
不能同时== 0
和>= 55
。
if (seatSelection >=56 && seatSelection >= 106)
如果seatSelection
是>= 106
,那么根据定义它也>= 56
,所以这个测试是多余的。
反正没关系,因为前面的if
语句不能true
,所以它永远不会被执行。
{
double seatSelectionCost = 0.00;
}
声明一个新变量,对其进行初始化,然后退出定义范围,这意味着该变量不再存在。代码毫无意义。
int seatSelection = Integer.parseIn( JOption.showInputDialog("Select your seat number")); //There is an additional charge if the seat selected is between seats 56 - 306
{
{
...
}
}
这些牙套的目的是什么?他们什么都不做。
对不起,我没有看其余的。 错误已经太多了。
您能否再次验证这些条件?
if (seatSelection == 0 && seatSelection >= 55)
{
if (seatSelection >=56 && seatSelection >= 106)
{
if (seatSelection >= 107 && seatSelection <=206)
{
if (seatSelection >= 207 && seatSelection <= 306)
{
double seatSelectionCost = 0.00;
}
double seatSelectionCost = 7.45;
}
double seatSelectionCost = 14.30;
}
double seatSelectionCost = 35.16;
}
这些代码永远不会执行。也许这就是你的意思?
if (seatSelection <= 55)
{
seatSelectionCost = 35.16;
}
else if (seatSelection <= 106)
{
seatSelectionCost = 14.30;
}
else if (seatSelection <=206)
{
seatSelectionCost = 7.45;
}
else if (seatSelection <= 306)
{
seatSelectionCost = 0.00;
}
末尾的大括号"}"丢失。这是您需要的代码
import javax.swing.JOptionPane;
public class Ticketpurchasingprogram {
public static void main (String[] args)
{
string customerName = JOptionPane.showInputDialog("Enter your name");
double ticketBaseCost = 10.60;
int seatSelection = Integer.parseIn( JOption.showInputDialog("Select your seat number")); //There is an additional charge if the seat selected is between seats 56 - 306
{
{if (seatSelection == 0 && seatSelection >= 55)
{
if (seatSelection >=56 && seatSelection >= 106)
{
if (seatSelection >= 107 && seatSelection <=206)
{
if (seatSelection >= 207 && seatSelection <= 306)
{
double seatSelectionCost = 0.00;
}
double seatSelectionCost = 7.45;
}
double seatSelectionCost = 14.30;
}
double seatSelectionCost = 35.16;
}
}
}
ticketSeatCost = ticketBaseCost + seatSlectionCost;
deliveryMethod = JOptionPane.showInputDialog("Would you like your ticket emailed or shipped?");
{if (deliveryMethod = "emailed")
{
if (deliveryMethod = "shipped")
{
double convenienceFee = ticketSeatCost * 0.03;
}
double convenienceFee = ticketSeatCost * 0.01;
}
}
totalCost = ticketSeatCost + convenienceFee;
JOptionPane.showMessageDialog(null, "**Eagle Bank Arena Ticket** 'n Customer Name: " + customerName + "'n Seat Number: " + seatNumber + "'n Delivery Method: " + deliveryMethod + "'n Ticket Base Cost: " + ticketBaseCost + "'n Seat Cost: " + seatSelectionCost + "'n Convenience Fee: " + convenienceFee + String.format("'n Total Cost $%.2f", totalCost));
}
}
相关文章:
- 咕噜声.js无法读取文件(错误代码:EISDIR)
- 在 ubuntu 14.04 VPS 上执行.js文件错误
- 命令代码jquery文件错误
- XMLHttpRequest无法加载Angular js中的文件错误
- 咕噜声/巴别塔错误:无法写入“dist”文件(错误代码:EISDIR)
- 未捕获的类型错误:对象[对象对象]在文件 y 错误中没有方法“x”
- angularjs + 下载 csv 文件 + 错误: [$injector:unpr] 未知提供程序
- 露天更新文件 - 错误开机自检
- Django ExtJs 6:上传文件错误
- Dropbox放入保护程序本地主机文件错误
- 我的网站在提交时出现文件错误
- php生成的JSON文件错误
- JSON文件错误
- 为什么Chrome开发者工具/控制台不显示javascript文件/错误是动态加载的
- 保存JSON文件错误
- Facebook Javascript表单数据照片上传:需要上传文件错误
- 如何在Node.js中上传文件?错误:无法POST/上载
- 外部javascript文件错误
- 使用jQuery表单插件上传文件-无效文件错误
- Json上传jquery文件错误