|
|
Mini-assignment 1: Generate a Sales Receipt
- Create a sales receipt for
a sale that contains at least five
different products (with prices of your
choosing).
- Display the products,
quantity of each product, price of each
product, and an "extended price". Be sure to
store the different prices in variables so the
program can be easily modified. Use an HTML
table to nicely format the output.
- Add the products' extended
prices together to get an overall subtotal for
the sale.
- Display the overall
subtotal.
- Calculate sales tax using
5.75% as your tax rate and display the
tax amount.
- Add together your overall
subtotal and the tax amount to get your total.
We won't worry about shipping or other costs
for now.
- Display your grand total in
bold print.
Example output:
Item |
quantity |
price |
extended
price |
Gillette Sensor 3 Razor |
2 |
$ 1.23 |
$ 2.46 |
Barbasol Shaving Cream |
1 |
$ 2.64 |
$ 2.64 |
Nautica Cologne |
1 |
$ 6.17 |
$ 6.17 |
Rubbing Alcohol
|
3 |
$ 0.98 |
$ 2.94 |
Colgate Classic Toothbrush
|
12 |
$ 1.89 |
$22.68 |
|
Sub-total |
$36.89 |
Tax @ 5.75% |
$ 2.12 |
Total |
$39.01 |
HINT: Use a real
sales receipt as your guide.
HINT: Use printf() or number_format() to
get your calculations to display exactly 2
decimal places.
HINT: Do not try to create the HTML table
first. Start by simply printing each row in the
table as an individual line. When you have
everything calculating and printing correctly,
add in the table tags. (You could even try
viewing the HTML for this page and copy
the HTML table in the example above and then use
it to change what you print in your print
statement.)
Grading
Criteria:
Comments |
5% |
Minimum five products |
5% |
Prices not hard coded |
10% |
Subtotal is calculated correctly |
20% |
Sales tax is calculated correctly |
15% |
Total is calculated correctly |
20% |
Amounts only have 2 decimal places |
5% |
HTML table display |
20% |
Submission:
Please submit a single .php file for this
assignment. Make sure that you name it:
LastName_FirstName_Mini_Asst1.php
Upload completed assignment to your
folder on itm-vm. Also upload your php file to
the Mini-Assignment 1 area on Laulima, and
indicate there the URL of your assignment on
itm-vm.
|