REQ: some sort of calc

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dastylex
Forum Newbie
Posts: 2
Joined: Sat Feb 09, 2008 9:10 am
Contact:

REQ: some sort of calc

Post by dastylex »

hi
im looking for some sort of php calculator...
like:
if i enter some value (suppose X value) into it.. it calculates 15% of that X value and add the result into X value..

for example..
X value = 230
it calculates like this 230 x 15% = 34.5
and it adds it back to X value.. in this case...
34.5 + 230 = 264.5


final result it must show is 264.5

nothing is to be changed.. only X value is variable and has to be changed everytime i want to calculate.

can u help me please? i want it urgent.
thanks
bye
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: REQ: some sort of calc

Post by Christopher »

Code: Select all

$percent = 15;
$x = 230;
$total = $x - ($x * ($percent / 100));
(#10850)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: REQ: some sort of calc

Post by John Cartwright »

arborint wrote:

Code: Select all

$percent = 15;
$x = 230;
$total = $x - ($x * ($percent / 100));
$x +

instead of

$x -

:mrgreen:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: REQ: some sort of calc

Post by Christopher »

Shows how ingrained discount calculations are in by brain. :crazy:
(#10850)
dastylex
Forum Newbie
Posts: 2
Joined: Sat Feb 09, 2008 9:10 am
Contact:

Re: REQ: some sort of calc

Post by dastylex »

sorry but guys.. im totally a noob in programming.. can u guide me how to make this thing work on php ? :oops:

so i dont have to put in percentage everytime.. i just enter the value and it shows the rslt!
Post Reply