IT 207 Practicum 1 Part2php

You might also like

You are on page 1of 3

Part2.

php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Lab Practicum 1: Part 2 Result</title>

<link rel="stylesheet" href="./practicumStyle.css" type="text/css" />


</head>
<body>
<div id="headerPortion">
<heading1>Midway Coupon Distributor</heading1>
</div>
<div id="bodyPortion">
<?php
$coupon = $_POST['coupons'];

define('candyBarCoupon', '10');

define('gumballCoupon', '3');

function circles($inputValue)
{
$output = "";
for($i=0; $i < $inputValue; $i++){

$output .= "o ";


}
return $output;
}
$remainderCoupon = $coupon % candyBarCoupon;
$candyCoup = $coupon / candyBarCoupon;
$candyCoup = (int)($candyCoup);
$Gumball = $remainderCoupon / gumballCoupon;
$gumingRemainder = $remainderCoupon % gumballCoupon;
$Gumball = (int)$Gumball;

$candyOutput = circles($candyCoup);
$gumballOutput = circles($Gumball);
$remainingOutput = circles($gumingRemainder);

echo "Your ".$coupon." coupons can be redeemed for: <br /><br />";
echo $candyCoup." Candy Bars<br />";
echo "$candyOutput<br /><br />";
echo $Gumball." Gumballs<br />";
echo "$gumballOutput<br /><br />";
echo $gumingRemainder." Left over coupons<br />";
echo "$remainingOutput<br /><br />";
?>
</div>
<div id="footerPortion">
<?php
echo "Legend: Candy Bar = ".candyBarCoupon." coupons "." | "." Gumball =
".gumballCoupon." coupons";
?>
</div>
<p>
<?php
date_default_timezone_set('EST');

echo "Last Modified: " . date ("H:i M d, Y, T", getlastmod()), " | ";
?>
<a
href="http://helios.vse.gmu.edu/~yourUserName/IT207/labpracticum1/part2.html">
Return to form page</a></p>

</body>
</html>

You might also like