} } } /* price of items */ $appetizer_price = 5.0; $drink_price = 3.0; $entree_price = 10.0; $dessert_price = 4.0; /* tax and tip additions */ $sales = 0.08; $tip = 0.15; $subtotal = $appetizer_price + $drink_price + $entree_price + $dessert_price; $tax = $subtotal * $sales; $tip = ($subtotal + $tax) * $tip; $grand = $subtotal + $tax + $tip; $drink = select_beverage($entree); ?> <br/> <h1>Here is what I ate and what it cost</h2> <ul> <li>As an appetizer I had <? echo $appetizer; ?> which cost $<? echo $appetizer_price; ?></li> <li>I drank <? echo $drink; ?> which cost $<? echo $drink_price; ?></li> <li>I ordered <? echo $entree; ?> which cost $<? echo $entree_price; ?></li> <li>For dessert, I ate <? echo $dessert; ?> which cost $<? echo $dessert_price; ?></li> <h3>My subtotal came to $<? echo number_format((float)$subtotal, 2, '.', ''); ?></h3> <h3>Uncle Sam’s share was $<? echo number_format((float)$tax, 2, '.', ''); ?></h3> <h3>My tip on the subtotal and tax came to $<? echo number_format((float)$tip, 2, '.', ''); ?> <h3>Add that all up, and I forked out $<? echo number_format((float)$grand, 2, '.', ''); ?>
} else { if ($dinner == "Barbecue Pork") { $beverage = "Sparkling Cider"; } else { if ($dinner == "Chicken") { $beverage = "Diet Coke"; } else { echo "ERROR: Please return to our menu and make a selection."; } } } } return $beverage; } //defines the $beverage value so it can be used in the tally $beverage = select_beverage($dinner); //this is where we display the data from the form and the function along with static HTML text $appetizer = "House Salad"; $drink = $beverage; $entree = $dinner; $dessert = "Apple Pie"; $appetizer_price = 5.95; $drink_price = 8.949999999999999; $entree_price = 9.75; $dessert_price = 4.75; $subtotal = $appetizer_price + $drink_price + $entree_price + $dessert_price; //cost of menu items in order $tax = $subtotal * 0.08; //cost with tax $tip = $subtotal * 0.15; //cost including tip