CrimsonZ Posted April 24, 2007 Share Posted April 24, 2007 I got it pretty much working, but can't do one specification. I am supposed to apply the discount(.25) before the tax is added(.06) then store the total in TotalCost. The quantity you see is what the user entered into a text box for how many widgets they want. The code I have now figures the tax, then applies the discount, throwing off my totals. Also please don't comment on the inefficiency of the code as my instructor makes us do certain things. if ($_GET[quantity]<1) { print "Please make sure that you have entered a quantity and then resubmit"; } else { $widget_cost = 20.00; $widget_rate = $widget_cost * $_GET[quantity]; $tax_rate = $widget_rate * .06; $total_rate = $tax_rate + $widget_rate; $payment = $total_cost/12; if ($widget_rate >= 50.00) { $disc_rate = $widget_rate * .25; $total_cost = $total_rate - $disc_rate; $disc_total = ", minus your $". $disc_rate . " discount,"; } else { $disc_rate = ""; } print "You requested " . $_GET[quantity] . " widgets(s) at $" . $widget_cost . " each."; print "Your total with tax" .$disc_total. " comes to $" .$total_cost. "."; print "You may purchase the widget(s) in 12 monthly installments of $" .round($payment, 2) . " each."; } Link to comment https://forums.phpfreaks.com/topic/48377-solved-simple-php-help/ Share on other sites More sharing options...
Barand Posted April 24, 2007 Share Posted April 24, 2007 Then why don't you calculate the discounted value before calculating the tax? Link to comment https://forums.phpfreaks.com/topic/48377-solved-simple-php-help/#findComment-236556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.