Posted: Sat Jan 22, 2011 10:37 am Post subject: Need help with Cash register program.
What is it you are trying to achieve?
A cash register program on Turing.
What is the problem you are having?
Every time on the program "What is the adult-clothing price?" or "What is the child-clothing price" it freezes and ends it's self
Describe what you have tried to solve this problem
I've tried putting the "end if" in different area's of the coding.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing:
var price, priceafterTax :real var atax :real:=0.13 var ctax :real:=0.06 var answer :string
put"What is the category? a=adult c=child 0=end" get answer
if answer ="a" then put"What is the Adult-clothing price?" get price
priceafterTax := price * atax + price
endif
if answer ="c" then put"What is the Child-clothing price?" get price
priceafterTax := price * atax + price
endif
Please specify what version of Turing you are using
Turing 4.1.1
Sponsor Sponsor
TokenHerbz
Posted: Sat Jan 22, 2011 10:43 am Post subject: RE:Need help with Cash register program.
theres nothing wrong with the code, but i think you forgot this line at the end.
Turing:
put"The price after tax is : $", priceafterTax
on second thought, see what your doing, your repeating some code there. Try to minimize that by going something like...
code:
if adult cloths then
ask price for adults cloths
elsif childs cloths then
ask price for childs cloths
end if
get price --->see only have to do this once instead of twice!
calculate total price -->> This too!
show price
Canadian
Posted: Sat Jan 22, 2011 11:17 am Post subject: Re: Need help with Cash register program.
Ohhhh Ok thank you so much i forgot about that end line lol. Thank you for the advice I'll shorten it