note 96112 deleted from control-structures.switch by thiago
| From: | thiago@php.net | Date: | Tue, 09 Feb 2010 12:10:50 +0000 |
| Subject: | note 96112 deleted from control-structures.switch by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165789@lists.php.net to get a copy of this message | ||
Note Submitter: 96352 at rsglingecollege dot nl
Reason: non-english
----
bloembollenfirma.
a. Maak een script waarin de prijs van de bloembollen voor de verschillende aantallen in een tabel
op het scherm wordt getoond.
b.Laat het script uitrekenen hoeveel het totaalbedrag van een bestelling is. Het aantal sla je op in
een variabele $bestelling, die verderop in de pagina samen met de totaalprijs wordt getoond. Je
hoeft je nog niet druk te maken over de correcte opmaak van het bedrag in euro's, als het
juiste bedrag maar wordt uitgerekend. Je ziet een voorbeeld in figuur 4.6 op blz 86 van het boek.
c.Varieer zowel het aantal bestelde bloemenbollen, de drempelwaarden als de prijs om te zien hoe het
script zich flexibel aanpast.
A.
<html>
<head>
<title>De bloembollenbestelbon</title>
<?php
$grens1=10;
$grens2=100;
$grens3=$grens2+1;
$grens4=250;
$prijs1=1.50;
$prijs2=1.35;
$prijs3=1.15;
$prijs4=0.90;
$aantal1=8;
$aantal2=0;
$aantal3=0;
$aantal4=0;
$bestelling=$aantal1+$aantal2+$aantal3+$aantal4;
$totaal=$aantal1*$prijs1+$aantal2*$prijs2+
$aantal3*$prijs3+$aantal4*$prijs4;
?>
</head>
<body>
<H1>Bestel nu uw bloembollen!</h1>
<table border="0">
<tr>
<td>
<table border="1">
<tr><th>Aantal bloembollen</th><th>
Prijs per stuk</th></tr>
<tr><td>minder dan <?php echo
$grens1; ?></td><td><?php echo $prijs1; ?> euro</td></tr>
<tr><td><?php echo "$grens1 tot
$grens2" ?></td><td><?php echo $prijs2; ?> euro</td></tr>
<tr><td><?php echo "$grens3 tot
$grens4" ?></td><td><?php echo
$prijs3; ?> euro</td></tr>
<tr><td>meer dan <?php echo
$grens4; ?></td><td><?php echo $prijs4; ?> euro</td></tr>
</table>
<h3>U bestelde <?php echo
$aantal; ?> bloembollen.</h3>
</td>
<td>
<img src="bloembol.jpg">
</td>
</tr>
</table>
<h3>De totaalprijs is <?php
echo $bestelling; ?> euro.</h3>
</body>
</html>
C.
<html>
<head>
<title>De bloembollenbestelbon</title>
<?php
$grens1=100;
$grens2=300;
$grens3=$grens2+1;
$grens4=500;
$prijs1=1.75;
$prijs2=1.5;
$prijs3=1.25;
$prijs4=1.1;
$aantal1=0;
$aantal2=0;
$aantal3=0;
$aantal4=750;
$bestelling=$aantal1+$aantal2+
$aantal3+$aantal4;
$totaal=$aantal1*$prijs1+$aantal2
*$prijs2+$aantal3*$prijs3+$aantal4*$prijs4;
?>
</head>
<body>
<H1>Bestel nu uw bloembollen!</h1>
<table border="0">
<tr>
<td>
<table border="1">
<tr><th>Aantal bloembollen</th>
<th>Prijs per stuk</th></tr>
<tr><td>minder dan <?php echo
$grens1; ?></td><td><?php echo
$prijs1; ?> euro</td></tr>
<tr><td><?php echo "$grens1 tot
$grens2" ?></td><td><?php echo $prijs2; ?> euro</td></tr>
<tr><td><?php echo "$grens3 tot
$grens4" ?></td><td><?php echo
$prijs3; ?> euro</td></tr>
<tr><td>meer dan <?php echo
$grens4; ?></td><td><?php echo
$prijs4; ?> euro</td></tr>
</table>
<h3>U bestelde <?php echo $bestelling; ?> bloembollen.</h3>
</td>
<td>
<img src="bloembol.jpg">
</td>
</tr>
</table>
<h3>De totaalprijs is <?php echo $totaal; ?> euro.</h3>
</body>
</html>