错误:无法找到"的符号

时间:2014-04-16 15:33:10

标签: java

我一直收到这个错误,我无法弄清楚为什么会继续发生。

C:\Users\Clay\Desktop>javac PartyOrder.java
PartyOrder.java:276: error: cannot find symbol
                srtInfo+="\n Banners" + banners + " @ $2.00  = "  + d1.format(ba
nners * 2.00) + " * Discount Rate: " + discount('N') + " = " + subtotal('N');
                ^
  symbol:   variable srtInfo
  location: class PartyOrder
1 error

C:\Users\Clay\Desktop>

这是源代码,我尝试过几次重写这行,但这也没有帮助。我在这里寻找类似的东西,但我无法找到它,感谢提前帮助。

import java.text.DecimalFormat;
public class PartyOrder
{
    int balloons;           //number of balloons
    int candles;            //number of candles
    int banners;            //number of banners ordered
    char    shippingOption; //either O,T,P
    DecimalFormat d1 = new DecimalFormat ( "$##0.00" );
    public PartyOrder()
    {

}//end PartyOrder()

public PartyOrder(int balloons, int candles, int banners, char shipping)
{
    balloons = this.balloons;
    candles = this.candles;
    banners = this.banners;
    shippingOption = shipping;
}//end PartyOrder(int,int,int,char)

public void setBalloons(int num)
{
    if (num>0)
        {
            balloons = num;
        }
}//end setBalloons(int)

public void setCandles(int num)
{
    if (num>0)
        {
            candles = num;
        }

}//end setCandles(int)

public void setBanners(int num)
{
    if (num>0)
        {
            banners = num;
        }
}//end setBanners(int)

public void setShipping(char option)
{
    if(option == 'O' && option == 'o')
        {;
            shippingOption = 'O';
        }
    else if (option == 'T' && option == 't')
        {
            shippingOption = 'T';
        }
    else if (option == 'P' && option == 'p')
        {
            shippingOption = 'P';
        }
    else
        {
            shippingOption = 'N';
        }
}//end setShipping(int)

public int getBalloons()
{
    return balloons;
}//end getBalloons()

public int getCandles()
{
    return candles;
}//end getCandles()

public int getBanners()
{
    return banners;
}//end getBanners()

public int getShipping()
{
    return shippingOption;
}//end getShipping()

public double shippingCost()
{
    double dShip;       //holds the value given in this method  
    dShip = 0.00;
    if (shippingOption == 'O')
        {
            dShip = 10.00;
        }
    else if (shippingOption == 'T')
        {
            dShip = 7.50;
        }
    else if (shippingOption == 'P')
        {
            dShip = 5.00;
        }
    else if (shippingOption == 'N')
        {
            dShip = 0.00;
        }

    return dShip;
}//end shippingCost()

public String shippingType()
{
    String strShip;     //holds the value given in this method  
    strShip = "";

        if (shippingOption == 'O')
                {
                    strShip = "Overnight";
                }
            else if (shippingOption == 'T')
                {
                    strShip = "Two-Day Shipping";
                }
            else if (shippingOption == 'P')
                {
                    strShip = "Priority Shipping";
                }
            else if (shippingOption =='N')
                {
                    strShip = "Normal (free) Shipping ";
                }
        return strShip;
}//end shippingType()

private double discount(char chr)
{
    double   dDisc;
    int      iTotal;
    iTotal = (balloons + banners + candles);
    dDisc = 0.00;

    while (chr == 'B')
    {
        if (iTotal <10)
            {
                dDisc = 0.00;
            }
        else if (iTotal >=10 && iTotal <20)
            {
                dDisc = 0.10;
            }
        else if (iTotal >=20 && iTotal <30)
            {
                dDisc = 0.15;
            }
        else if (iTotal >=30 && iTotal <40)
            {
                dDisc = 0.20;
            }
        else if (iTotal >=40)
            {
                dDisc = 0.25;
            }
    }// end while

    while (chr == 'C')
    {
        if (iTotal <10)
            {
                dDisc = 0.00;
            }
        else if (iTotal >=10 && iTotal <20)
            {
                dDisc = 0.10;
            }
        else if (iTotal >=20 && iTotal <30)
            {
                dDisc = 0.15;
            }
        else if (iTotal >=30 && iTotal <40)
            {
                dDisc = 0.20;
            }
        else if (iTotal >=40)
            {
                dDisc = 0.25;
            }
    }// end while 

    while (chr == 'N')
    {
        if (iTotal <10)
            {
                dDisc = 0.00;
            }
        else if (iTotal >=10 && iTotal <20)
            {
                dDisc = 0.10;
            }
        else if (iTotal >=20 && iTotal <30)
            {
                dDisc = 0.15;
            }
        else if (iTotal >=30 && iTotal <40)
            {
                dDisc = 0.20;
            }
        else if (iTotal >=40)
            {
                dDisc = 0.25;
            }
    }// end while 

    return dDisc;

}//end discount(char)

private double subtotal(char chr)
{
    double dSub;
    dSub = 0.00;

    if (chr == 'B')
        {
            dSub = ((balloons * 2.50)*(discount('B'))) + (balloons * 2.50);
        }
    else if (chr == 'C')
        {
            dSub = ((candles * 6.00)*(discount('C'))) + (candles * 6.00);
        }
    else if (chr == 'N')
        {
            dSub = ((banners * 2.00)*(discount('N'))) + (banners* 2.00);
        }

    return dSub;
}//end subtotal(char)

public double subtotal()
{
    double  dSubtot;
    dSubtot = 0.00;

    dSubtot = subtotal('B')+ subtotal('C') + subtotal('N');

    return  dSubtot;
}//end subtotal()

public double tax()
{
    double dTax;
    dTax = (.05 * subtotal());
    return dTax;
}//end tax()

public double orderTotal()
{
    double  dTotal;
    dTotal = subtotal() + tax() + shippingCost();
    return  dTotal;
}//end orderTotal()

public String invoice()
{
    String strInfo;

    strInfo = " Balloons" + balloons +" @ $2.50  = " + d1.format(balloons * 2.50) + " * Discount Rate: " + discount('B') + " = " + subtotal('B');
    strInfo+="\n Candles" + candles + " @ $6.00  = "  + d1.format(candles * 6.00) + " * Discount Rate: " + discount('C') + " = " + subtotal('C');
    srtInfo+="\n Banners" + banners + " @ $2.00  = "  + d1.format(banners * 2.00) + " * Discount Rate: " + discount('N') + " = " + subtotal('N');



    return strInfo;
}//end invoice()

1 个答案:

答案 0 :(得分:3)

你把srtInfo而不是strInfo。简单的拼写错误。 ;)

&#34;符号&#34;它找不到的是srtInfo,而不是"。它指向引号的唯一原因是因为换行......