none
Cash Register Program RRS feed

  • Question

  • I have no idea how to fix this.

    Sorry, we found some errors...

    86,17: Unrecognized statement encounter.

    87,18: Unrecognized statement encounter.

    88,18: Unrecognized statement encounter.

    89,18: Unrecognized statement encounter.

     returnedvalue2 * CheeseBurgerCost = sum2
      returnedvalue3 * LargeDrinkcost = sum3
      returnedvalue4 * Friescost = sum4
      returnedvalue5 * tacoscost = sum5

    using small basic and shouldnt that work?
    and....

    Body text cannot contain images or links until we are able to verify your account???????????

    'You have been hired to create a ordering software title for Big Green Burger. The software should give 

    'the user the options to take an order, display the order, and print a receipt to the screen.

    'The interface should look like the one below:

    'Welcome to Big Green Burger

    '----------------------------------------------

    'Select a choice below

    '1) Take Order
    '2) Calculate Cost
    '3) Print Receipt

    'Make Your Selection: ____

    'Take Order

    '1) Cheese Burger ----- $4.00
    '2) Large Drink ----------$1.00
    '3) Fries -------------------$2.34
    '4) Tacos ------------------$0.50
    '5) Go Back to Main Menu

    'Make Your Selection: ____
    'Cheese Burger --------- 2X

     CheeseBurgerCost = 4
     LargeDrinkcost = 1
      Friescost = 2.34
     tacoscost = 0.50
    TextWindow.WriteLine ("Take Order")
    TextWindow.WriteLine ("Calculate Cost")
    TextWindow.WriteLine ("Print Receipt")
    TextWindow.WriteLine (" ")
    TextWindow.WriteLine ("Select a choice above")
    returnedvalue = TextWindow.Readnumber()
    TextWindow.Clear()

    'Take Order
    if returnedvalue = 1 then
      TextWindow.WriteLine ("Select choices below")
      TextWindow.WriteLine ("1. Cheese Burger")
      TextWindow.WriteLine ("2. Large Drink")
      TextWindow.WriteLine ("3. Fries")
      TextWindow.WriteLine ("4. Tacos")
        TextWindow.WriteLine (" ")

      TextWindow.WriteLine ("How many cheeseburgers?")
      returnedvalue2 = TextWindow.ReadNumber()
        TextWindow.WriteLine ("How many large drinks?")
        returnedvalue3 = TextWindow.ReadNumber()
          TextWindow.WriteLine ("How many fries?")
          returnedvalue4 = TextWindow.ReadNumber()
            TextWindow.WriteLine ("How many tacos?")
     returnedvalue5 = TextWindow.ReadNumber()

    TextWindow.Clear()
    TextWindow.WriteLine ("Take Order")
      TextWindow.WriteLine ("Calculate Cost")
    TextWindow.WriteLine ("Print Receipt")
    TextWindow.WriteLine (" ")
    TextWindow.WriteLine ("Select a choice above")
    returnedvalue = TextWindow.Readnumber()
    TextWindow.Clear()



     
    endif
    If returnedvalue = 2 Then
     
       CheeseBurgerCost = 4
     LargeDrinkcost = 1
      Friescost = 2.34
     tacoscost = 0.50
     
     returnedvalue2 * CheeseBurgerCost = sum2
      returnedvalue3 * LargeDrinkcost = sum3
      returnedvalue4 * Friescost = sum4
      returnedvalue5 * tacoscost = sum5
     
      TextWindow.WriteLine ("sum2 + sum3 +sum4 + sum5")
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
    TextWindow.WriteLine ("Take Order")
      TextWindow.WriteLine ("Calculate Cost")
    TextWindow.WriteLine ("Print Receipt")
    TextWindow.WriteLine (" ")
    TextWindow.WriteLine ("Select a choice above")
    returnedvalue = TextWindow.Readnumber()
    TextWindow.Clear()
    EndIf
          
          If returnedvalue= 3 Then
            
    TextWindow.WriteLine("Big Green Burger")
    TextWindow.WriteLine(" ")
    TextWindow.WriteLine("Cheeseburger:  " + returnedvalue2 * x + sum2)
    TextWindow.WriteLine("Large Drinks:  " + returnedvalue3 * x + sum3)
    TextWindow.WriteLine("Fries:  " + returnedvalue4 * x + sum4)
    TextWindow.WriteLine("Tacos:   " + returnedvalue5 * x + sum5)

          
          Endif




    • Edited by Dinomite07 Saturday, August 16, 2014 3:08 AM
    Saturday, August 16, 2014 2:42 AM

Answers

  • I'm not familiar with SmallBasic but it looks like you assignment operations are backwards. I tried looking some examples online and it looks like normal assignment rules should be followed. i.e.:

    A= B*C 

    not 

    B*C=A

    So

     returnedvalue2 * CheeseBurgerCost = sum2
      returnedvalue3 * LargeDrinkcost = sum3
      returnedvalue4 * Friescost = sum4
      returnedvalue5 * tacoscost = sum5

    should be

    sum2= returnedvalue2 * CheeseBurgerCost 
    sum3=  returnedvalue3 * LargeDrinkcost 
    sum4=  returnedvalue4 * Friescost 
    sum5=  returnedvalue5 * tacoscost


    • Proposed as answer by TopGunMSDN Saturday, August 16, 2014 2:29 PM
    • Marked as answer by litdevModerator Sunday, September 7, 2014 2:29 PM
    Saturday, August 16, 2014 4:38 AM
  • Do you want to loop the whole program (from line 1)?

    - make te first line :              while "True"

    - make the last line :            endwhile

    - put in the body:    if returnvalue=0 then

                                      program.end()

                                   endif


    Jan [ WhTurner ] The Netherlands

    Saturday, August 16, 2014 1:46 PM
    Answerer
  • Hello,

    Your variable drinkcost is not reset because in your Sub Variable you set drinkost to zero. (add a c in the name).

    As a hint: put all subroutines after the main program (the lines not in a sub). In that way it is easier to see where the program starts.


    Jan [ WhTurner ] The Netherlands

    Wednesday, August 20, 2014 1:52 PM
    Answerer
  • Hello, Dinomite07

    Adding on WhTurner33's answer, I took your code and rewrote it with a while loop. The integrity of your program remains pretty much the same, except I used some different coding techniques. I also changed the beginning of your program so that the user is sent directly to ordering their food and the total cost is written out when the order is complete. You don't have to keep it this way, but I hope I made it a bit easier to understand while loops and code structuring. If you have any questions please let me know. I also recommend looking at the Small Basic Wiki and curriculum. Both of these have plenty of information and tips about small basic and programming in general. For your convenience, I have the links to these resources posted here.

    small basic curriculum:  http://social.technet.microsoft.com/wiki/contents/articles/16299.small-basic-curriculum.aspx

    small basic wiki: http://social.technet.microsoft.com/wiki/contents/articles/17553.wiki-small-basic-portal.aspx

    You could also access these and much more from the Small Basic home page: http://smallbasic.com/ 

    LF = Text.GetCharacter(10) 'Creates spacing between lines of text 
    
    While "True"
      TextWindow.WriteLine("Hello, welcome to Big Green Burger. Press any button to order. . ." + LF)
      TextWindow.PauseWithoutMessage() 
      TextWindow.Clear() 
      
      menu() 
      TextWindow.WriteLine ("Enter your order . . . ")
      yourOrder() 
      TextWindow.Clear() 
      calculateCost() 
      costOfOrder() 
      reOrderOp() 
    EndWhile 
    
    Sub menu 
      TextWindow.WriteLine("BIG GREEN BURGER MENU")
      TextWindow.WriteLine("Cheese Burger 4.00 ea.") 
      TextWindow.WriteLine("Large Drink 1.00 ea.") 
      TextWindow.WriteLine("Fries 2.34 ea.")  
      TextWindow.WriteLine("Tacos 0.50 ea."+LF) 
    EndSub 
    
    Sub yourOrder 
      TextWindow.WriteLine ("How many cheese burgers do you want?")
      numOfCB = TextWindow.ReadNumber()
      TextWindow.WriteLine ("How many large drinks do you want? ")
      numOfLD = TextWindow.ReadNumber() 
      TextWindow.WriteLine ("How many order of fries do you want? ")
      numOfF = TextWindow.ReadNumber() 
      TextWindow.WriteLine ("How many tacos do you want? ")
      numOfT = TextWindow.ReadNumber() 
    EndSub 
    
    Sub calculateCost
      costOfCB = numOfCB*4
      costOfLD = numOfLD*1
      costOfF = numOfF*2.34
      costOfT = numOfT*0.5
      
      totalCost = costOfCB + costOfLD + costOfF + costOfT 
    EndSub 
    
    Sub costOfOrder 
      TextWindow.WriteLine("Your order: ")
      TextWindow.WriteLine("Cheese Burger(s) . . . . " + numOfCB)
      TextWindow.WriteLine("Large Drinks(s) . . . . " + numOfLD) 
      TextWindow.WriteLine("Order of Fries . . . . " + numOfF)
      TextWindow.WriteLine("Order of Tacos . . . . " + numOfT + LF) 
      TextWindow.WriteLine("Total: " + totalCost+LF)
    EndSub 
    
    Sub reOrderOp
      TextWindow.WriteLine("Would you like to re-order?") 
      TextWindow.WriteLine("Enter Y Or N . . .")
      response = TextWindow.Read()
      If (response = "n" Or response = "N") Then
        TextWindow.Clear()  
        receipt() 
        TextWindow.PauseWithoutMessage()
        Program.End()
      Else 
        TextWindow.Clear()   
      EndIf
    EndSub
    
    Sub receipt 
      TextWindow.WriteLine("Thank you for choosing the Big Green Burger. Here's your receiept."+LF) 
      costOfOrder() 
      TextWindow.WriteLine("Next Customer . . . ")
    EndSub 


    Sunday, August 17, 2014 1:02 AM

All replies

  • I'm not familiar with SmallBasic but it looks like you assignment operations are backwards. I tried looking some examples online and it looks like normal assignment rules should be followed. i.e.:

    A= B*C 

    not 

    B*C=A

    So

     returnedvalue2 * CheeseBurgerCost = sum2
      returnedvalue3 * LargeDrinkcost = sum3
      returnedvalue4 * Friescost = sum4
      returnedvalue5 * tacoscost = sum5

    should be

    sum2= returnedvalue2 * CheeseBurgerCost 
    sum3=  returnedvalue3 * LargeDrinkcost 
    sum4=  returnedvalue4 * Friescost 
    sum5=  returnedvalue5 * tacoscost


    • Proposed as answer by TopGunMSDN Saturday, August 16, 2014 2:29 PM
    • Marked as answer by litdevModerator Sunday, September 7, 2014 2:29 PM
    Saturday, August 16, 2014 4:38 AM
  • I'm not familiar with SmallBasic but it looks like you assignment operations are backwards. I tried looking some examples online and it looks like normal assignment rules should be followed. i.e.:

    A= B*C 

    not 

    B*C=A

    So

     returnedvalue2 * CheeseBurgerCost = sum2
      returnedvalue3 * LargeDrinkcost = sum3
      returnedvalue4 * Friescost = sum4
      returnedvalue5 * tacoscost = sum5

    should be

    sum2= returnedvalue2 * CheeseBurgerCost 
    sum3=  returnedvalue3 * LargeDrinkcost 
    sum4=  returnedvalue4 * Friescost 
    sum5=  returnedvalue5 * tacoscost

    ty it worked

    im new to programming


    Saturday, August 16, 2014 4:56 AM
  • Small basic i finally finished the program but have no idea how to loop it
    TextWindow.WriteLine ("Take Order")
    TextWindow.WriteLine ("Calculate Cost")
    TextWindow.WriteLine ("Print Receipt")
    TextWindow.WriteLine (" ")
    TextWindow.WriteLine ("Select a choice above")
    returnedvalue = TextWindow.Readnumber()
    TextWindow.Clear()
    
    if returnedvalue = 1 then 
      TextWindow.WriteLine ("Select choices below")
      TextWindow.WriteLine ("1. Cheese Burger")
      TextWindow.WriteLine ("2. Large Drink")
      TextWindow.WriteLine ("3. Fries")
      TextWindow.WriteLine ("4. Tacos")
      TextWindow.WriteLine (" ")
    
       TextWindow.WriteLine ("How many cheeseburgers?")
       returnedvalue2 = TextWindow.ReadNumber()
       TextWindow.WriteLine ("How many large drinks?")
       returnedvalue3 = TextWindow.ReadNumber()
      TextWindow.WriteLine ("How many fries?")
       returnedvalue4 = TextWindow.ReadNumber()
       TextWindow.WriteLine ("How many tacos?")
       returnedvalue5 = TextWindow.ReadNumber()
       TextWindow.PauseWithoutMessage()
    
    TextWindow.Clear()
    TextWindow.WriteLine ("Take Order")
    TextWindow.WriteLine ("Calculate Cost")
    TextWindow.WriteLine ("Print Receipt")
    TextWindow.WriteLine (" ")
    TextWindow.WriteLine ("Select a choice above")
    returnedvalue = TextWindow.Readnumber()
    TextWindow.Clear()
    
    endif
    If returnedvalue = 2 Then
      
      sum2 = returnedvalue2 * 4 
      sum3 = returnedvalue3 * 1 
      sum4 = returnedvalue4 * 2.34 
      sum5 = returnedvalue5 * 0.50
      total = sum2 + sum3 + sum4 + sum5
      
      TextWindow.WriteLine ("Cost: $ " + total)
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
      TextWindow.WriteLine ("Take Order")
      TextWindow.WriteLine ("Calculate Cost")
      TextWindow.WriteLine ("Print Receipt")
      TextWindow.WriteLine (" ")
      TextWindow.WriteLine ("Select a choice above")
      returnedvalue = TextWindow.Readnumber()
      TextWindow.Clear()
    EndIf
          
          If returnedvalue= 3 Then
            
    TextWindow.WriteLine("Big Green Burger")
    TextWindow.WriteLine(" ")
    TextWindow.WriteLine("Cheeseburgers: " + returnedvalue2) 
    TextWindow.WriteLine ("Cost: $ " + sum2)
    TextWindow.WriteLine("Large Drinks: " + returnedvalue3)
    TextWindow.WriteLine ("Cost: $ " + sum3)
    TextWindow.WriteLine("Fries: "+ returnedvalue4)
    TextWindow.WriteLine ("Cost: $ " + sum4)
    TextWindow.WriteLine("Tacos: " + returnedvalue5)
    TextWindow.WriteLine ("Cost: $ " + sum5)
    TextWindow.PauseWithoutMessage()
         
    Endif

    Saturday, August 16, 2014 5:46 AM
  • Do you want to loop the whole program (from line 1)?

    - make te first line :              while "True"

    - make the last line :            endwhile

    - put in the body:    if returnvalue=0 then

                                      program.end()

                                   endif


    Jan [ WhTurner ] The Netherlands

    Saturday, August 16, 2014 1:46 PM
    Answerer
  • Hello, Dinomite07

    Adding on WhTurner33's answer, I took your code and rewrote it with a while loop. The integrity of your program remains pretty much the same, except I used some different coding techniques. I also changed the beginning of your program so that the user is sent directly to ordering their food and the total cost is written out when the order is complete. You don't have to keep it this way, but I hope I made it a bit easier to understand while loops and code structuring. If you have any questions please let me know. I also recommend looking at the Small Basic Wiki and curriculum. Both of these have plenty of information and tips about small basic and programming in general. For your convenience, I have the links to these resources posted here.

    small basic curriculum:  http://social.technet.microsoft.com/wiki/contents/articles/16299.small-basic-curriculum.aspx

    small basic wiki: http://social.technet.microsoft.com/wiki/contents/articles/17553.wiki-small-basic-portal.aspx

    You could also access these and much more from the Small Basic home page: http://smallbasic.com/ 

    LF = Text.GetCharacter(10) 'Creates spacing between lines of text 
    
    While "True"
      TextWindow.WriteLine("Hello, welcome to Big Green Burger. Press any button to order. . ." + LF)
      TextWindow.PauseWithoutMessage() 
      TextWindow.Clear() 
      
      menu() 
      TextWindow.WriteLine ("Enter your order . . . ")
      yourOrder() 
      TextWindow.Clear() 
      calculateCost() 
      costOfOrder() 
      reOrderOp() 
    EndWhile 
    
    Sub menu 
      TextWindow.WriteLine("BIG GREEN BURGER MENU")
      TextWindow.WriteLine("Cheese Burger 4.00 ea.") 
      TextWindow.WriteLine("Large Drink 1.00 ea.") 
      TextWindow.WriteLine("Fries 2.34 ea.")  
      TextWindow.WriteLine("Tacos 0.50 ea."+LF) 
    EndSub 
    
    Sub yourOrder 
      TextWindow.WriteLine ("How many cheese burgers do you want?")
      numOfCB = TextWindow.ReadNumber()
      TextWindow.WriteLine ("How many large drinks do you want? ")
      numOfLD = TextWindow.ReadNumber() 
      TextWindow.WriteLine ("How many order of fries do you want? ")
      numOfF = TextWindow.ReadNumber() 
      TextWindow.WriteLine ("How many tacos do you want? ")
      numOfT = TextWindow.ReadNumber() 
    EndSub 
    
    Sub calculateCost
      costOfCB = numOfCB*4
      costOfLD = numOfLD*1
      costOfF = numOfF*2.34
      costOfT = numOfT*0.5
      
      totalCost = costOfCB + costOfLD + costOfF + costOfT 
    EndSub 
    
    Sub costOfOrder 
      TextWindow.WriteLine("Your order: ")
      TextWindow.WriteLine("Cheese Burger(s) . . . . " + numOfCB)
      TextWindow.WriteLine("Large Drinks(s) . . . . " + numOfLD) 
      TextWindow.WriteLine("Order of Fries . . . . " + numOfF)
      TextWindow.WriteLine("Order of Tacos . . . . " + numOfT + LF) 
      TextWindow.WriteLine("Total: " + totalCost+LF)
    EndSub 
    
    Sub reOrderOp
      TextWindow.WriteLine("Would you like to re-order?") 
      TextWindow.WriteLine("Enter Y Or N . . .")
      response = TextWindow.Read()
      If (response = "n" Or response = "N") Then
        TextWindow.Clear()  
        receipt() 
        TextWindow.PauseWithoutMessage()
        Program.End()
      Else 
        TextWindow.Clear()   
      EndIf
    EndSub
    
    Sub receipt 
      TextWindow.WriteLine("Thank you for choosing the Big Green Burger. Here's your receiept."+LF) 
      costOfOrder() 
      TextWindow.WriteLine("Next Customer . . . ")
    EndSub 


    Sunday, August 17, 2014 1:02 AM
  • 
    Sub variable
      cb = 0
      ld = 0
      fs = 0
      ts = 0
      burgercost = 0
      drinkost = 0
      friescost = 0
      tacoscost = 0
      itemcost = burgercost + drinkcost + friescost + tacoscost
      totalitemcost = itemcost * tax
      taxd = .09 
      itemm = itemcost * taxd
      tax = 1.09
    EndSub
    
    variable()
    clear()
    Menu()
    
    Sub clear
      TextWindow.Clear()
    endsub
    
    Sub hello
      TextWindow.Title = "Big Green Burger"
      TextWindow.WriteLine ("Cash Register")
    EndSub
     
    Sub Menu
    TextWindow.WriteLine ("1. Take Order")
    TextWindow.WriteLine ("2. Calculate Cost")
    TextWindow.WriteLine ("3. Print Receipt")
    TextWindow.WriteLine (" ")
    TextWindow.WriteLine ("Select a choice above")
    omg = TextWindow.Read()
    If omg = 1 Then
       clear()
       Order()  
     ElseIf omg = 2 Then
       clear()
       Calculation()  
     Elseif omg = 3 then
       clear()
       Receipt()
     Else
       clear()
       Menu()
     EndIf
    EndSub
    
    Sub Order
       clear()
       TextWindow.WriteLine ("Select choices below")
       TextWindow.WriteLine (" ")
       TextWindow.WriteLine ("1. Cheese Burger")
       TextWindow.WriteLine ("2. Large Drink")
       TextWindow.WriteLine ("3. Fries")
       TextWindow.WriteLine ("4. Tacos")
       TextWindow.WriteLine (" ")
       TextWindow.WriteLine ("5. Back")
       TextWindow.WriteLine (" ")
       cost()
       TextWindow.WriteLine (" ")
       lol = TextWindow.Read()
      If lol = 1 Then
        cb = cb + 1
        burgercost = burgercost + 4
        TextWindow.Clear()
        Order()
        cost()
      ElseIf lol = 2 Then
        ld = ld + 1
        drinkcost = drinkcost + 1
        TextWindow.Clear()
        Order()
        cost()
      ElseIf lol = 3 Then
        fs = fs + 1
        friescost = friescost + 2.34
        TextWindow.Clear()
        Order()
        cost()
       Elseif lol = 4 Then
        ts = ts + 1
        tacoscost = tacoscost + .5
        TextWindow.Clear()
        Order()
        cost()
       Elseif lol = 5 Then
        TextWindow.Clear()
        Menu()  
       Else
        TextWindow.Clear()
        Order()
       EndIf
    EndSub
    
    Sub Calculation
      TextWindow.WriteLine("Cheese Burger " + "x" + cb + " $" + burgercost)
      TextWindow.WriteLine("Large Drink " + "x" + ld + " $" + drinkcost)
      TextWindow.WriteLine("Fries " + "x" + fs + " $" + friescost)
      TextWindow.WriteLine("Tacos " + "x" + ts + " $" + tacoscost)
      TextWindow.WriteLine (" ")
      TextWindow.WriteLine ("Cost: $" + itemcost)
      TextWindow.WriteLine ("Tax: $" + itemm) 
      TextWindow.WriteLine("Total Cost: $" + totalitemcost)
      TextWindow.WriteLine (" ")
      TextWindow.WriteLine ("1. Menu")
      TextWindow.WriteLine ("2. Receipt")
      irs = TextWindow.Read()
      If irs = 1 Then
        TextWindow.Clear()
        Menu()
      elseIf irs = 2 Then
        TextWindow.Clear()
        Receipt()
      Else 
        TextWindow.Clear()
        Calculation()
      endif
    EndSub
    
    Sub Receipt
      cost()
      TextWindow.WriteLine(" ")
      TextWindow.Pause()
      clear()
      variable()
      Menu()
    EndSub 
      
      sub cost
      itemcost = burgercost + drinkcost + friescost + tacoscost
      totalitemcost = itemcost * tax
      taxd = .09 
      itemm = itemcost * taxd
      tax = 1.09
      TextWindow.WriteLine ("Big Green Burger")
      TextWindow.WriteLine(" ")
      TextWindow.WriteLine("Cheese Burger " + "x" + cb + " $" + burgercost)
      TextWindow.WriteLine("Large Drink " + "x" + ld + " $" + drinkcost)
      TextWindow.WriteLine("Fries " + "x" + fs + " $" + friescost)
      TextWindow.WriteLine("Tacos " + "x" + ts + " $" + tacoscost)
      TextWindow.WriteLine(" ")
      TextWindow.WriteLine ("Cost: $" + itemcost)
      TextWindow.WriteLine ("Tax: $" + itemm) 
      TextWindow.WriteLine("Total Cost: $" + totalitemcost)
    EndSub 

    Taking Order

    Calculating Cost

    Reciept

    If I go back to Take Order. Some numbers are still there when they need to be cleared? I don't know what is wrong. Small Basic

    Wednesday, August 20, 2014 1:10 AM
  • Hello,

    Your variable drinkcost is not reset because in your Sub Variable you set drinkost to zero. (add a c in the name).

    As a hint: put all subroutines after the main program (the lines not in a sub). In that way it is easier to see where the program starts.


    Jan [ WhTurner ] The Netherlands

    Wednesday, August 20, 2014 1:52 PM
    Answerer