<?php
/* $Qunatity must be passed to this page from a form or via the URL. $Discount is optional. */
$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;
// 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>");
?>
You requested to purchase 0 widget(s) at $2000 each.
The total with tax, minus your $0, comes to $0.00.
You may purchase the widget(s) in 12 monthly installments of $0.00 each.