1) Create one php file with the 4 parts. Each part should do the following:
If sales is between 2000 and 3000, the percentage to calculate the bonus is .10
If sales is between 3001 and 4000, the percentage to calculate the bonus is .20
If sales is greater than 4000, the percentage to calculate the bonus is .30
Anything else gets a 0 for the bonus percentage
City | State |
Boston |
Massachusetts |
Chicago |
Illinois |
Miami |
Florida |
New York |
New York |
the default should be 'United States' is something else is in $city |
If you have any doubts, please give me comment...
<?php
// Part-1
$i=1;
while($i<=15){
echo $i." ";
$i++;
}
echo "<br />";
// Part-2
for($i=10; $i<=20; $i++){
echo $i." ";
}
echo "<br />";
// Part-3
$sales = 5000;
if($sales>=2000 && $sales<=3000)
$bonus_pct = 0.10;
else if($sales>=3001 && $sales<=4000)
$bonus_pct = 0.20;
else if($sales>4000)
$bonus_pct = 0.30;
else
$bonus_pct = 0;
echo "Bonus Percentage: ".$bonus_pct;
echo "<br />";
//Part-4
$city = "Boston";
switch($city){
case "Boston":
echo "Massachusetts";
break;
case "Chicago":
echo "Illinois";
break;
case "Miami":
echo "Florida";
break;
case "New York":
echo "New York";
break;
default:
echo "United States";
break;
}
?>
Get Answers For Free
Most questions answered within 1 hours.