Computer Science Canada

HELP- Adding number not working

Author:  simon66 [ Tue Dec 02, 2008 2:15 pm ]
Post subject:  HELP- Adding number not working

hey... First of all, hey everyone... My problem today is that my turing program is not adding. Here is my code.
Quote:
%This is a restaurant bill
var cost:string
var second:string
var third:string
loop
put "Choose a Meal!"
put "(1) Chicken Sandwich $3,00"
put "(2) Chicken Soup $2,00"
put "(3) Coffe $1,00"
put "(4) Large Fries $2,00"
get cost
if cost ="4" then
cost:="2,00"
end if
if cost ="3" then
cost:="1,00"
end if
if cost="2"then
cost:="2,00"
end if
if cost="1"then
cost:="3,00"
end if
exit when cost > "4"
put "Would you like to add anything else with your order?(y/n)"
get second
if second = "n" then
put "Your Total is $",cost
else
put "Add your second meal!"
get third
if third ="1"then
third:="3,00"
end if
if third="2"then
third:="2,00"
end if
if third="3"then
third:="1,00"
end if
if third="4"then
third:="2,00"
end if
put "Your total is ", third + cost
end if
end loop

were is says "Your total is", third + cost is not adding properly instead of adding 2+1 it gives me 21 and not 3. any help? Thnx

Author:  Clayton [ Tue Dec 02, 2008 2:27 pm ]
Post subject:  RE:HELP- Adding number not working

third and cost are both strings, not ints. You need those strings to become ints. Check out the Turing Walkthrough for the tutorial on String Manipulation.


: