You are on page 1of 1

Omar Carrillo

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;

# Print out the total


print "Total = \$$total";

?>

Output

Total = $15.6845

CS 479 - PHP Programming - Summer 2009 - NMSU

W ith PDFmyURL anyone can convert entire websites to PDF!

You might also like