I'm doing this exercise from a book but the calulation does not seem to be working.
I put the $Quantity and $Discount vlaes after the url (i.e. ?Quantity=10&Discount=5) but I keep on gettinga minus even though I use abs to get an absolute figure....
<?php
/* $Quantity has to passed to this web page from either a form, in the URL or on this page */
$Cost = 2000.00;
$Tax = 0.06;
$Quantity = abs($Quantity);
$Discount = abs($Discount);
$Tax++; // $Tax is now worth 1.06
$TotalCost = (($Cost * Quantity) - $Discount) * $Tax;
$Payments = round ($TotalCost, 2) / 12;
// Now print the results
print ("You requested to purchase $Quantity widget(s) at \$$Cost each.\n<P>"
print ("The total with tax, minus your \$$Discount, comes to $"
printf ("%01.2f", $TotalCost);
print (".\n<P>You may purchase the widget(s) in 12 monthly installments of $"
printf ("%01.2f", $Payments);
print (" each.\n<P>"
?>
thanks for any help or suggestions given...
I put the $Quantity and $Discount vlaes after the url (i.e. ?Quantity=10&Discount=5) but I keep on gettinga minus even though I use abs to get an absolute figure....
<?php
/* $Quantity has to passed to this web page from either a form, in the URL or on this page */
$Cost = 2000.00;
$Tax = 0.06;
$Quantity = abs($Quantity);
$Discount = abs($Discount);
$Tax++; // $Tax is now worth 1.06
$TotalCost = (($Cost * Quantity) - $Discount) * $Tax;
$Payments = round ($TotalCost, 2) / 12;
// Now print the results
print ("You requested to purchase $Quantity widget(s) at \$$Cost each.\n<P>"
print ("The total with tax, minus your \$$Discount, comes to $"
printf ("%01.2f", $TotalCost);
print (".\n<P>You may purchase the widget(s) in 12 monthly installments of $"
printf ("%01.2f", $Payments);
print (" each.\n<P>"
?>
thanks for any help or suggestions given...