1. Berapa biaya harus dibayar jika asumsi pelanggan akan fotocopysejumlah 158 lembar? .
Buat scriptdengan menggunakan kondisi If-Else untuk menampilkan biaya fotocopy.
<html>
<head>
<title>Hasil biaya </title>
</head>
<body>
Hasil Biaya <br>
<?php
$jum = $_POST['jumlah'];
$hasil;
if ($jum < 100)
{
$tarif = 150;
$hasil= $jum * $tarif ;
echo "Jumlah Lembar Fotocopy = $jum <br>";
echo "Tarif harga = $tarif <br>";
echo "Biaya harus bayar = $hasil <br>";
} else if ($jum < 200)
{
$tarif = 100;
$hasil= $jum * $tarif;
echo "Jumlah Lembar Fotocopy = $jum <br>";
echo "Tarif harga = $tarif <br>";
echo "Biaya harus bayar = $hasil <br>";
}else if ($jum < 200 )
{
$tarif = 80;
$hasil= $jum * $tarif ;
echo "Jumlah Lembar Fotocopy = $jum <br>";
echo "Tarif harga = $tarif <br>";
echo "Biaya harus bayar = $hasil <br>";
}else{
echo "Jumlah tidak sesuai";
}
?>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Formulir</title>
</head>
<body>
<form action="hasil.php" method="post">
Formulir
<table>
<tr>
<td> Jumlah lembar fotocopy</td>
<td><input type="text" name="jumlah"></td>
</tr>
<tr>
<td colspan ="2"><input type="submit" name="hitung" value="Hitung"></td>
</tr>
</table>
</form>
</body>
</html>
$nilai = 90;
?>
Berikut outputnya
3. Jumlah Hari dalam Sebulan
<?php
$jumHari = cal_days_in_month(CAL_GREGORIAN, 3, 2020);
echo "Ada ".$jumHari. "hari dalam bulan Maret tahun 2020";
?>