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

Username:   Password: 
 RegisterRegister   
 Need help with Cash register program.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Canadian




PostPosted: 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
end if


if answer = "c"
        then
    put "What is the Child-clothing price?"
    get price
    priceafterTax := price * atax + price
end if




Please specify what version of Turing you are using
Turing 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




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




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


Style:  
Search: