From c47afed9e62c321f8f7c67e0a2f3af2c9dcc4b2c Mon Sep 17 00:00:00 2001 From: wildscotsmen Date: Mon, 10 Apr 2017 03:55:26 -0400 Subject: [PATCH] First version. --- cashier.php | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 cashier.php diff --git a/cashier.php b/cashier.php new file mode 100644 index 0000000..da6e013 --- /dev/null +++ b/cashier.php @@ -0,0 +1,58 @@ +$item) { + echo "Item #" . ($num + 1) . " Price: " . $item . "\n"; +} +echo "\nSubtotal: " . $subtotal . "\n"; +echo "Tax: " . round(($subtotal * tax), 2) . "\n"; +echo "Total: " . $total . "\n\n"; + +// Loop for driving change entry +while(true) { + if ($total < 0) { + echo "\nYour change is " . round((-1 * $total), 2) . ". Have a nice day.\n"; + break; + } else if ($total == 0) { + echo "\nHave a nice day.\n"; + } + $input = readline("Insert payment value: "); + if (!is_numeric($input)) { + echo "Invalid value. Try again.\n"; + } + $total = round($total - (float)$input, 2); + if ($total > 0) { + echo "Remaining total is: " . $total . "\n"; + } +} +?>