i need help making the tip rate work. so it doesnt only do the 15% but whatever percent you choose
if (array_key_exists(‘Calculate’,$_POST)){
// for the first exercise
$userBill = $_POST[‘bill’];
if (is_numeric($userBill)) {
$suggestedTip = calTip($userBill);
$output = “The suggested tip is $suggestedTip”;
} else {
$output = “Please type in your bill amount, numbers only.”;
}
}
function calTip($bill){
$tip = $bill * 0.15;
return $tip;
}
Tip Calculator
What is the amount of the bill? $What is the tip rate? %
<?php echo "
"; echo $output; ?>