Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

RE: FN-FORUM: ASP Maths Problem!

date posted 1st February 2008 11:07

Peter Wilson wrote:
> Hi All,
>
> I know it's Friday but can anyone help with this maths problem?
>
> I have a client with an online shop written in ASP, they want to add
> a 20% payable field on the checkout page. So basically you see the
> total, the vat, then the total+the vat, under this 20% of the
> total+vat
>
> This is ASP for the total:
>
>
>
> How would I take this and work out 20%?
>
> TIA

I would do something like this

dblVATRate = 17.5
intPctPayable = 20

dblVATTotal = (intTotal) + (intTotal * dblVATRate/100)
dblPayable = dblVATTotal * intPctPayable/100

Calculate the VAT total then the Payable amount into separate variables for
clarity (I am not a big fan of calculating in the output statement even
though it is less code and I personally like to split out parameters that
may change (really should be defined as constants I guess, but YMMV).

Then output as




In response to a couple of resposne posts about making 17.5/100 be 0.175, to
be fair to the original author the original more clearly states the logic as
VAT is commonly expressed as 17.5% not as 0.175 albeit they are numerically
equal. Performance difference would be negligible.

HTH,

Dai



Messages by Day
February 29th 2008
February 28th 2008
February 27th 2008
February 26th 2008
February 25th 2008
February 24th 2008
February 23rd 2008
February 22nd 2008
February 21st 2008
February 20th 2008
February 19th 2008
February 18th 2008
February 17th 2008
February 16th 2008
February 15th 2008
February 14th 2008
February 13th 2008
February 12th 2008
February 11th 2008
February 10th 2008
February 9th 2008
February 8th 2008
February 7th 2008
February 6th 2008
February 5th 2008
February 4th 2008
February 3rd 2008
February 2nd 2008
February 1st 2008


Messages by Month
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000