
-----------------------------------
Wajih
Mon Jan 10, 2011 2:13 pm

I need help- Turing Calculator prgoram
-----------------------------------
What is it you are trying to achieve?What is the problem you are having?
i am having trouble with the not= operator

Describe what you have tried to solve this problem

hey guys i need help for my program. I need to know why it is saying "operands of Boolean operators must be boolean."

the part that says that is the :

 if symbol not= "*" or "/" or "+" or "-" then 
    cls 
    put "I'm sorry, you have entered an invalid symbol. Please try again."
    put ""
    end if    

i need help as to why it is saying this. 

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Here is my code :

var num, num2 : real := 0
var symbol : string
var sum : int := 0


locate (1, 28)
put "C A L C U L A T O R" ..


locate (3, 28)
put "F  U N C T I O N S :" ..


locate (5, 1)
put " MULTIPLICATION" ..


locate (5, 25)
put " DIVISION" ..


locate (5, 44)
put " ADDITION" ..


locate (5, 62)
put " SUBTRACTION"
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 symbol not= "*" or "/" or "+" or "-" then 
    cls 
    put "I'm sorry, you have entered an invalid symbol. Please try again."
    put ""
    end if    



    if sum = 5 then
        delay (1200)
        exit when sum = 5
    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
 10) OR (y < 12) then
   ...
[/code]

-----------------------------------
DemonWasp
Mon Jan 10, 2011 2:31 pm

RE:I need help- Turing Calculator prgoram
-----------------------------------
What this means is that to say "if symbol is NOT one of {+,-,*,/}" you have to say:

[code]if ( symbol not= "+" and symbol not="-" and symbol not="*" and symbol not="/" ) then[/code]

Note that you need to change from "symbol is not one of" to "symbol is not the first AND symbol is not the second AND symbol is not the third AND ..." .

-----------------------------------
Wajih
Mon Jan 10, 2011 3:55 pm

RE:I need help- Turing Calculator prgoram
-----------------------------------
Alright. Thanks Tony and DemonWasp. It works now. 

ps you guys are awesome :P
