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

Username:   Password: 
 RegisterRegister   
 turing code error loop
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
thuvi




PostPosted: 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 Very Happy thank you
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: 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?
crossley7




PostPosted: 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
Raknarg




PostPosted: 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]
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  [ 4 Posts ]
Jump to:   


Style:  
Search: