Java错误:解析

时间:2016-02-15 04:54:16

标签: javascript java 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));   

}

3 个答案:

答案 0 :(得分:0)

您还可以再次验证这些条件吗?

        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;
        }

答案 1 :(得分:0)

该代码中存在很多错误,因此很难知道从哪里开始。

if (seatSelection == 0 && seatSelection >= 55)

seatSelection不能同时为== 0>= 55

if (seatSelection >=56 && seatSelection >= 106)

如果seatSelection>= 106,那么根据定义它也是>= 56,因此测试是多余的。

无论如何,因为前一个if语句不能是true,所以它永远不会被执行。

{
    double seatSelectionCost = 0.00;
}

声明 new 变量,初始化它,然后退出定义范围,这意味着该变量不再存在。代码没有意义。

int seatSelection = Integer.parseIn( JOption.showInputDialog("Select your seat number")); //There is an additional charge if the seat selected is between seats 56 - 306
  {
    {
       ...
    }
  }

那些牙套的目的是什么?他们什么都不做。

对不起,我没看其余的。已经有太多错误。

答案 2 :(得分:-1)

你的大括号&#39;}&#39;最后遗失了。 继承你需要的代码

Function RefDocs(r As Range, c As Range, x As Range) As String
'   Generates a list of references for X

'   Variables
'   r - range for the vertical IDs (e.g. A2:A16)
'   c - range for horizontal IDs (e.g. B1:P1
'   x - the cell you've got the document ID you're cross referencing

    Dim lOffset As Long
    Dim rg As Range, rFind As Range

        Set rFind = r.Find(What:=x.Value)

        If rFind Is Nothing Then Exit Function

        lOffset = rFind.Row - c.Row

        With r.Parent
            For Each rg In c
                If rg.Offset(lOffset, 0).Value = "X" Then
                    RefDocs = RefDocs & .Cells(c.Row, rg.Column).Value & "; "
                End If
            Next rg
        End With
End Function