java - Error: cannot find symbol for a " -
i keep getting error , cannot figure out why continues happen.
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> here source code, have tried rewriting line several times, didn't either. looked on here similar couldn't find it, in advance.
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 value given in 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 value given in 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()
you put srtinfo instead of strinfo. simple typo. ;)
the "symbol" isn't finding srtinfo, not ". reason points @ quotation mark because of line wrapping...
Comments
Post a Comment