Computer Science Canada turing code error loop |
Author: | thuvi [ Sun Feb 26, 2012 8:51 pm ] |
Post subject: | turing code error loop |
I am trying to create a code in which you can calculate the sum difference product and quotient of two integers. I want to ask the user if they want to try it again, but I don't know why its not working. this is my code : % Declaration section var theSecondInteger : real var theFirstInteger : real var sum : real var difference : real var product : real var quotient : real var response : string var yes : string var no : string % Input section put "Hello." put "I will calculate the sum, difference, product, and quotient" put "of two integers of your choice." loop put "What is your first integer? " .. get theFirstInteger put "What is your second integer? " .. get theSecondInteger % Processing section sum := theFirstInteger + theSecondInteger difference := theFirstInteger - theSecondInteger product := theFirstInteger * theSecondInteger quotient := theFirstInteger / theSecondInteger % Output section put "The sum is ", sum put "The difference is ", difference put "The product is ", product put "The quotient is ", quotient put "Thank you!" put "Would you like to calculate another amount?" get response if response = yes % continue then response := no % exit end if end loop please help me thank you |
Author: | Raknarg [ Sun Feb 26, 2012 9:10 pm ] |
Post subject: | RE:turing code error loop |
Be more specific; What are you trying to do that it's failing to accomplish? |
Author: | crossley7 [ Sun Feb 26, 2012 10:58 pm ] |
Post subject: | RE:turing code error loop |
maybe look at the if statement condition. If they want to continue then what does it actually do? Think about it and you should come up with an answer to your problem |
Author: | Raknarg [ Mon Feb 27, 2012 9:41 am ] |
Post subject: | RE:turing code error loop |
whoops, didn't see that -.-' Yeah,youjust have it set up wrong. This is the kind of thing you're looking for [syntax="turing"] if (this thing happens) then do_this_thing () elsif (the other thing happens) then do_other_thing () end if [/yntax] |