Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 HELP- Adding number not working
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
simon66




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: