Computer Science Canada Turing Cash Register Assignment. Help Needed |
Author: | Sarah.Cameron [ Sun Oct 25, 2020 6:44 pm ] |
Post subject: | Turing Cash Register Assignment. Help Needed |
What is it you are trying to achieve? <Replace all the <> with your answers/code and remove the <>> I have to create a Cash Register program What is the problem you are having? <Answer Here> In the receipt of my cash register program, I have to include the name of the item the user wants and how many times they have ordered it, but i really dont know how to do it. help is really needed Describe what you have tried to solve this problem <Answer Here> I tried using if statements and a counter, but i think im doing it wrong Heres my code : put "Welcome to the Cash Register!" put "Enter in the password (case sensitive)" loop get pass count := count +1 if pass = "ICS" or count = 3 then exit else put "Invalid Password, Try Again" end if end loop if count = 3 and pass not= "ICS" then put "Access Denied" else put "Welcome to Cash Register at Alex's Burgers!" put "How many meals will you be ordering today? (No more than 10 meals permitted)" get meals loop if meals > 10 then put "Invalid number of meals" get meals end if if meals <=10 then exit end if end loop for i : 1 .. meals put "*************Menu***************" put "* 1. Hamburger, $9.95 *" put "* 2. Cheeseburger, $9.95 *" put "* 3. Mega Burger, $9.95 *" put "* 4. Ultra Burger, $9.95 *" put "* 5. Ultimate Burger, $9.95 *" put "********************************" put "What burger was ordered?" put i, ": ".. get item end for end if subtotal := meals * 9.95 taxcost := subtotal * TAXRATE totalCost:= taxcost + subtotal put "The order will cost $", totalCost : 6:2 , " after taxes." put "What was the amount of cash the customer paid in?" get cash loop if cash < totalCost or cash > 200 then put "Not enough cash was paid, or the maximum amount of payable cash was surpassed (Max $200)" get cash end if if cash = totalCost or cash <=200 and cash >totalCost then put "*************RECEIPT**************" put " " put "Subtotal : $ ", subtotal : 6:2 put "GST (13%) : $ ", taxcost : 6:2 put repeat ("=", 35) put "Total : $ ", totalCost : 6:2 put "Cash : $ ", cash : 6:2 change := cash - totalCost put "Change : $ ", change : 6:2 exit end if end loop |
Author: | scholarlytutor [ Fri Oct 30, 2020 10:54 am ] |
Post subject: | RE:Turing Cash Register Assignment. Help Needed |
One problem I can see immediately is that the variable count has not been declared. Before your loop: var count : int := 0 Note that I also initialized the variable to zero. This is necessary - you can't do count + 1 unless the variable already has a value. So that's why you make count start at zero. So fix that first and let me know if you're having trouble with the other code. |