Sign in to follow this  
Followers 0
onestcoder

Percentages

6 posts in this topic

What i'm tring to do is to do a simple calculate:

and have it round to the nearest cent.

ex:

$325.50 + 10% = ???

I have an input box for the percent. In it the user will typy "10" for 10%

here are the vars.

$total_price = 325.50 ;(or what they enter into the input box)

$markup_percent = 10 ; (or what they enter into the input box)

$makeup_amount = ???

$total_price_after_markup =???


Need a website: http://www.iconixmarketing.com

Share this post


Link to post
Share on other sites



$markup_amount=round(100*$total_price/$markup_percent,2)
$total_price_after_markup=$markup_amount + $total_price


Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Share this post


Link to post
Share on other sites

That works THANK you I just need to swich some var

$markup_amount=round($markup_percent/100*$total_price,2)

$total_price_after_markup=$markup_amount + $total_price


Need a website: http://www.iconixmarketing.com

Share this post


Link to post
Share on other sites

The order of multiplying and dividing does not matter at all, try both, you will get the same answer.


Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The order of multiplying and dividing does not matter at all, try both, you will get the same answer.

true .... but are you sure about the fomula?

shouldn't that be? :

$markup_amount=round($total_price*$markup_percent/100,2)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sorry, I mixed up my formula. I divided the total price by decimal percent. You are correct grandmaster JdeB.

@ OP

Sorry for the confusion.


Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0