Computer Science Canada Turing Calculator |
Author: | Wajih [ Mon Jan 10, 2011 8:52 pm ] | ||
Post subject: | Turing Calculator | ||
What is it you are trying to achieve? I am trying to add exponents into my calculator What is the problem you are having? i do not know how to do it. Describe what you have tried to solve this problem i tried creating a variable and running it through some loops but that did not work Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) var num, num2 : real := 0 var symbol : string var sum : int := 0 drawfillbox (100, 350, 520, 420, black) locate (1, 17) put "W A J I H' S T U R I N G C A L C U L A T O R" .. locate (3, 30) put "F-U-N-C-T-I-O-N-S :" .. locate (5, 2) put " MULTIPLICATION" locate (5, 25) put " DIVISION" locate (5, 44) put " ADDITION" locate (5, 62) put " SUBTRACTION" .. put "" put "" put "" loop put "Please enter your first number : " .. get num put "" put "Please enter your second number: " .. get num2 put "" put "Please enter your symbol. The symbol can only be (*) , (/), (+), or (-) " get symbol put "" if symbol = "*" then put "You have selected to input the multiplication symbol" put "" put "Your two numbers will now be multiplied" put "" put "Your new answer is now : ", num * num2 put "" sum := sum + 1 end if if symbol = "/" then put "You have selected to input the division symbol" put "" put "Your two numbers will now be divided" put "" put "Your new answer is now : ", num / num2 put "" sum := sum + 1 end if if symbol = "+" then put "You have selected to input the addition symbol" put "" put "Your two numbers will now be added" put "" put "Your new answer is now : ", num + num2 put "" sum := sum + 1 end if if symbol = "-" then put "You have selected to input the subtraction symbol" put "" put "Your two numbers will now be subtracted" put "" put "Your new answer is now : ", num - num2 put "" sum := sum + 1 end if if sum = 1 then put "You have 4 answers remaining." put "" elsif sum = 2 then put "You have 3 answers remaining." put "" elsif sum = 3 then put "You have 2 answers remaining." put "" elsif sum = 4 then put "You have 1 answer remaining." put "" end if if sum = 5 then delay (1200) exit when sum = 5 end if if (symbol not= "*") and (symbol not= "/") and (symbol not= "+") and (symbol not= "-") then cls put "I'm sorry, but you have entered an invalid symbol. Please try again." put "" end if end loop if sum = 5 then delay (100) cls put "You have no answers remaining." .. put "If you want to try this program again, please" put "close this window " .. put "and hit the run button." put "Otherwise, thank you for trying Wajih's Turing Calculator" end if
Please specify what version of Turing you are using i am using 4.1.1 |
Author: | RandomLetters [ Mon Jan 10, 2011 8:59 pm ] |
Post subject: | RE:Turing Calculator |
Turing has a built in exponents operator (**) ie: 2**3 = 8 |
Author: | Wajih [ Mon Jan 10, 2011 9:37 pm ] |
Post subject: | RE:Turing Calculator |
no that is not what i meant. i want the user to enter a number say 24. then the user has to enter another number say 3. i want calculator to do 24 * 24 * 24. that is what i need help with. |
Author: | Tony [ Mon Jan 10, 2011 9:40 pm ] |
Post subject: | RE:Turing Calculator |
24**3 |