locked
question about program RRS feed

  • 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

    TextWindow.Write("Please enter purchase amount:$")
    purchaseAmount = TextWindow.Read()
    TextWindow.Write("Please enter number of items:")
    numberOfItems = TextWindow.Read()
    TextWindow.Write("Please enter state code:")
    stateCode = TextWindow.Read()
    subTotal = purchaseAmount * numberOfItems
    TextWindow.WriteLine("your sub total is:$" + subTotal)
    if stateCode = "OR" then
      TextWindow.Write("your total tax is:$0")
     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
    grandTotal = subTotal + TextWindow.ReadNumber()
    TextWindow.WriteLine("your grandtotal is:$" + subTotal + grandTotal)

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

    thanks for your time

    Wednesday, March 5, 2014 9:06 PM

Answers

  • 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.

    TextWindow.Write("Please enter purchase amount:$")
    purchaseAmount = TextWindow.Read()
    TextWindow.Write("Please enter number of items:")
    numberOfItems = TextWindow.Read()
    TextWindow.Write("Please enter state code:")
    stateCode = TextWindow.Read()
    statecode=text.ConvertToUpperCase(statecode)
    subTotal = purchaseAmount * numberOfItems
    TextWindow.WriteLine("your sub total is:$" + subTotal)
    if stateCode = "OR" then
      StateTax= 0
      TextWindow.WriteLine("your total tax is: $"+StateTax)
    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 litdev Thursday, March 6, 2014 1:33 PM
    • Marked as answer by Nonki Takahashi Wednesday, March 19, 2014 10:40 AM
    Wednesday, March 5, 2014 11:11 PM
    Answerer

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.

    TextWindow.Write("Please enter purchase amount:$")
    purchaseAmount = TextWindow.Read()
    TextWindow.Write("Please enter number of items:")
    numberOfItems = TextWindow.Read()
    TextWindow.Write("Please enter state code:")
    stateCode = TextWindow.Read()
    statecode=text.ConvertToUpperCase(statecode)
    subTotal = purchaseAmount * numberOfItems
    TextWindow.WriteLine("your sub total is:$" + subTotal)
    if stateCode = "OR" then
      StateTax= 0
      TextWindow.WriteLine("your total tax is: $"+StateTax)
    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 litdev Thursday, March 6, 2014 1:33 PM
    • Marked as answer by Nonki Takahashi Wednesday, March 19, 2014 10:40 AM
    Wednesday, March 5, 2014 11:11 PM
    Answerer
  • 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