# Percentages

## Recommended Posts

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 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 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 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 on other sites

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

Live for the present,
Dream of the future,
Learn from the past.

##### 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.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...