Professional Documents
Culture Documents
Solutions
Homework 1
Assignment
Problem 1
Problem 2
Problem 2 Write a PHP program that computes the total cost of this restaurant meal: two hamburgers at $4.95 each, one
chocolate milk shake at $1.95, and a cola at 85 cents. The sales tax rate is 7.5% (.075), and you left a pre-tax
Problem 3 tip of 16% (.016)
Problem 4 Solution
Problem 5 <?php
Problem 6 # variables
$hamburguer=4.95;
$shake=1.95;
$soda=0.85;
$tax_rate=0.075;
$tip_rate=0.16;
# computations
$subtotal = ($hamburguer * 2) + $shake + $soda;
$tax = $subtotal * $tax_rate;
$tip = $subtotal * $tip_rate;
$total = $subtotal + $tip + $tax;
?>
Output
Total = $15.6845