Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-20-2005, 01:29 PM calculating in forms
capetek's Avatar
Extreme Talker

Posts: 229
Location: Massachusetts
Trades: 0
Well Im trying to make a quote calculator, I have the first one done but im having trouble with variables for the other ones. the first quote is as follows:

v=sale amount

up to $200

x=v*42.9%

201-500

y=$85.80+((v-200)*37.9%))


500 and up

z=$275.30+((v-500)*27.9%))

Does anyone know if y and z are even possible in php? U can calculate just a percentage of 42.9 percent but can i add more mathematical functions to that? and if someone knows how? It would be greatly appreciated if someone could help me. I am willing to compensate for the help they gave me.


The php code:

PHP Code:
<body>
 
 <?php
 
 
if ($sub_total == "") { echo "<h4>Error: You need to input a total!</h4>";}
 
 if (
$tip_percent == "") { echo "<h4>Error: You need to input a tip percentage!</h4>";}
 
 
$tip_decimal $tip_percent/100;
 
 
$tip $tip_decimal $sub_total;
 
 
$total $sub_total $tip;
 
 
?>
 
 <form action="tips.php3" method="get">
 
 <p>Consignment Price: <strong>$<?php echo $sub_total?></strong></p>
 
 <p>Commission%: <strong><?php echo $tip_percent?>%</strong></p>
 
 <p>Commission Total: <strong>$<?php echo $tip?></strong></p>
 
 <p>Total Price: <font size="+1" color="#990000"><strong>$<?php echo $total?></strong></font></p>
 
 </form>
 
 </body>

and the form code:

HTML Code:
<body>
Sales Up to $200 <br>

<form action="tips.php3" method="get">

<p>Consignment Cost: $
  <input type="text" name="sub_total" value="" size="7"></p>

<p>Commission Rate  %: 
  <input type="text" name="tip_percent" value="42.9" size="3">%</p>

<p><input type="submit" value="Calculate!"></p>

</form>
Sales $201-$500<br>
<form action="tips.php3" method="get">

<p>Consignment Cost: $
  <input type="text" name="sub_total" value="" size="7"></p>

<p>Commission Rate  %: 
  <input type="text" name="tip_percent" value="42.9" size="3">%</p>

<p><input type="submit" value="Calculate!"></p>

</form>
Sales $500 and up <br>
<form action="tips.php3" method="get">

<p>Consignment Cost: $
  <input type="text" name="sub_total" value="" size="7"></p>

<p>Commission Rate  %: 
  <input type="text" name="tip_percent" value="42.9" size="3">%</p>

<p><input type="submit" value="Calculate!"></p>

</form>
</body>
__________________
Anthony LeBoeuf
Cape-Tek IT Solutions

Please login or register to view this content. Registration is FREE

Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
 
Register now for full access!
Old 04-20-2005, 01:39 PM
capetek's Avatar
Extreme Talker

Posts: 229
Location: Massachusetts
Trades: 0
does anyone know if this would be correct?

$total = 85.80 + ($sub_total - 200) * $tip ;
__________________
Anthony LeBoeuf
Cape-Tek IT Solutions

Please login or register to view this content. Registration is FREE

Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
Old 04-20-2005, 01:52 PM
angele803's Avatar
Perfectly Imperfect

Posts: 1,772
Name: Stephanie
Location: Oklahoma
Trades: 2
You should be able to use x, y, and z as variables. Im not really sure I understand what calculations you are needing help with. Are the calculation you posted for the ones that work or the ones you are having trouble with?
angele803 is offline
Reply With Quote
View Public Profile
 
Old 04-20-2005, 02:02 PM
capetek's Avatar
Extreme Talker

Posts: 229
Location: Massachusetts
Trades: 0
well I have the first one working correctly but the 2nd and 3rd ones i dont, Im working ont he second one right now and this is what i have so far

tips2.php

PHP Code:
 <?php
 
 
if ($sub_total == "") { echo "<h4>Error: You need to input a total!</h4>";}
 
 if (
$tip_percent == "") { echo "<h4>Error: You need to input a tip percentage!</h4>";}
 
 
$tip_decimal $tip_percent/100;
 
 
$price85.80;
 
 
$tip $tip_decimal $sub_total;
 
 
$total =  $price + (($sub_total 200) * $tip) ;
 
 
?>

but doesnt seem to be calculating it correctly,

you can see it in action here

thanks for your response
__________________
Anthony LeBoeuf
Cape-Tek IT Solutions

Please login or register to view this content. Registration is FREE

Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
Old 04-20-2005, 02:14 PM
angele803's Avatar
Perfectly Imperfect

Posts: 1,772
Name: Stephanie
Location: Oklahoma
Trades: 2
Okay, I am starting to see what you are doing now. So, for example. If the sales amount is $250, the first 200 would be calculated with a percentage rate of 42.9 and the remaining 50 would be calculated with the percentage rate of 37.9. Is this correct?
angele803 is offline
Reply With Quote
View Public Profile
 
Old 04-20-2005, 02:16 PM
angele803's Avatar
Perfectly Imperfect

Posts: 1,772
Name: Stephanie
Location: Oklahoma
Trades: 2
Or is it this way...
If it is between 201 and 500 the entire total is calculated with the percentage of 37.9?
angele803 is offline
Reply With Quote
View Public Profile
 
Old 04-20-2005, 02:19 PM
capetek's Avatar
Extreme Talker

Posts: 229
Location: Massachusetts
Trades: 0
Yeah thats exactly what im doing, the 2nd response. heh this thing is driving me crazy

v=sale amount

x=v*42.9%
y=$85.80+((v-200)*37.9%))
z=$275.30+((v-500)*27.9%))

x=sales up to $200
y= sales from $201-500
z=sales >$500

i thought i had it again but nope!

PHP Code:
 <?php
 
 
if ($sub_total == "") { echo "<h4>Error: You need to input a total!</h4>";}
 
 if (
$tip_percent == "") { echo "<h4>Error: You need to input a tip percentage!</h4>";}
 
 
$tip_decimal $tip_percent/100;
 
 
$price 85.80;
 
 
$tip $price + (($sub_total 200) *  $tip_decimal);
 
 
$total $sub_total $tip;
 
 
?>
__________________
Anthony LeBoeuf
Cape-Tek IT Solutions

Please login or register to view this content. Registration is FREE

Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
Old 04-20-2005, 02:25 PM
capetek's Avatar
Extreme Talker

Posts: 229
Location: Massachusetts
Trades: 0
Oh wait I think thats correct!
__________________
Anthony LeBoeuf
Cape-Tek IT Solutions

Please login or register to view this content. Registration is FREE

Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
Old 04-20-2005, 02:29 PM
angele803's Avatar
Perfectly Imperfect

Posts: 1,772
Name: Stephanie
Location: Oklahoma
Trades: 2
Okay, say the sales amount is $250. I would pay a commision of $94.75 (250*37.9%) for a grand total of 344.75 (250+94.75)? Right?
You could do this in one step with this expression (salesAmount*1.379)
Im not sure what the 85.80 is for and why you are subtracting 200. I think I might still be confused. Sorry!
angele803 is offline
Reply With Quote
View Public Profile
 
Old 04-20-2005, 02:53 PM
capetek's Avatar
Extreme Talker

Posts: 229
Location: Massachusetts
Trades: 0
Hehe im not quite sure about those totals myself, the customer gave them to me. But i think i got it anyways, i did the math out on paper and it equals the same as my quote calculator

this was the correct way

PHP Code:
 <?php
 
 
if ($sub_total == "") { echo "<h4>Error: You need to input a total!</h4>";}
 
 if (
$tip_percent == "") { echo "<h4>Error: You need to input a tip percentage!</h4>";}
 
 
$tip_decimal $tip_percent/100;
 
 
$price 85.80;
 
 
$tip $price + (($sub_total 200) *  $tip_decimal);
 
 
$total $sub_total $tip;
 
 
?>
and for the 3rd section

PHP Code:
 <?php
 
 
if ($sub_total == "") { echo "<h4>Error: You need to input a total!</h4>";}
 
 if (
$tip_percent == "") { echo "<h4>Error: You need to input a tip percentage!</h4>";}
 
 
$tip_decimal $tip_percent/100;
 
 
$price 275.30;
 
 
$tip $price + (($sub_total 500) *  $tip_decimal);
 
 
$total $sub_total $tip;
 
 
?>

Thanks for your help!
__________________
Anthony LeBoeuf
Cape-Tek IT Solutions

Please login or register to view this content. Registration is FREE

Great hosting at affordable pricing!
capetek is offline
Reply With Quote
View Public Profile Visit capetek's homepage!
 
Reply     « Reply to calculating in forms
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31420 seconds with 12 queries