• ### Question

• I'm writing a program for my class at school and can't figure out why my grand total at the end of the program isn't subtracting my if statement to get total wages after tax here is the program

subTotal = purchaseAmount * numberOfItems
TextWindow.WriteLine("your sub total is:\$" + subTotal)
if stateCode = "OR" then
else
if stateCode = "WA" then
Textwindow.Write("your tax total is:\$" + subTotal * .065)
else
if stateCode = "CA" then
TextWindow.Write("your tax total is:\$" * subTotal * .0825)
EndIf
EndIf
EndIf
TextWindow.WriteLine("your grandtotal is:\$" + subTotal + grandTotal)

Im wondering what the textwindow.readnumber() in the grandTotal line needs to be changed to.

Wednesday, March 5, 2014 9:06 PM

• gafler,

Here's your program back with slight modifiction.  Basically, I created a variable to hold the State Tax once it was computed.  For the statecode I used a convert to uppercase function as I always kept forgetting to type in caps.  You should be able to modify this to exactly what you want.

statecode=text.ConvertToUpperCase(statecode)
subTotal = purchaseAmount * numberOfItems
TextWindow.WriteLine("your sub total is:\$" + subTotal)
if stateCode = "OR" then
StateTax= 0
else
if stateCode = "WA" then
StateTax=subTotal * .065
Textwindow.WriteLine("your tax total is: \$" + StateTax)
else
if stateCode = "CA" then
StateTax=subTotal * .0825
TextWindow.WriteLine("your tax total is: \$" + StateTax)
EndIf
EndIf
EndIf
TextWindow.WriteLine("your grandtotal is: \$" + (subTotal + StateTax))

JR

• Proposed as answer by Thursday, March 6, 2014 1:33 PM
• Marked as answer by Wednesday, March 19, 2014 10:40 AM
Wednesday, March 5, 2014 11:11 PM

### All replies

• gafler,

Here's your program back with slight modifiction.  Basically, I created a variable to hold the State Tax once it was computed.  For the statecode I used a convert to uppercase function as I always kept forgetting to type in caps.  You should be able to modify this to exactly what you want.

statecode=text.ConvertToUpperCase(statecode)
subTotal = purchaseAmount * numberOfItems
TextWindow.WriteLine("your sub total is:\$" + subTotal)
if stateCode = "OR" then
StateTax= 0
else
if stateCode = "WA" then
StateTax=subTotal * .065
Textwindow.WriteLine("your tax total is: \$" + StateTax)
else
if stateCode = "CA" then
StateTax=subTotal * .0825
TextWindow.WriteLine("your tax total is: \$" + StateTax)
EndIf
EndIf
EndIf
TextWindow.WriteLine("your grandtotal is: \$" + (subTotal + StateTax))

JR

• Proposed as answer by Thursday, March 6, 2014 1:33 PM
• Marked as answer by Wednesday, March 19, 2014 10:40 AM
Wednesday, March 5, 2014 11:11 PM
• thanks, I appreciate the help now I see what I was missing. So simple yet so easy to miss when your just starting out.
Thursday, March 6, 2014 4:19 AM