Posted: 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
Dreadnought
Posted: 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?