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

Username:   Password: 
 RegisterRegister   
 Accumulator Question + Counter
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SucreTeen123




PostPosted: Wed May 23, 2012 10:55 am   Post subject: Accumulator Question + Counter

Okay so my goal is to add prices together with 13% tax included in the toal bill and somehow include counter into it. But right now I am stuck on how to add them together properly. When I
try to add numbers together with the tax number it doesn't work properly. Please help!


%Calculating Page

var purchasecost : real
var taxmoney : real
taxmoney := 0
var total : real
total := 0
const tax := 0.13
var answer : string


loop
put "Please enter the cost of the item you wish to purchase"
put "Type in 0 to exit program"
get purchasecost

if purchasecost = 0 then
put "Are you sure (Y/N)"
get answer

exit when answer = "y" or answer = "Y"
end if

taxmoney := purchasecost * tax
total := taxmoney + purchasecost
end loop



put "The total cost for the CDs are ", total, " dollars."
Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Wed May 23, 2012 3:21 pm   Post subject: Re: Accumulator Question + Counter

You want to accumulate a total. So you want to add to the total.
Turing:
total := taxmoney + purchasecost

This says "set the total to this value".
What you want is for the "value" to be the sum of the total and the purchase and tax. How can you do this?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: