Created
February 21, 2020 02:07
-
-
Save rizkiv1/5fdf58322fd607baa252c287b5d4ae17 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<title>Sistem Diskon</title> | |
</head> | |
<body> | |
<div> | |
Sistem Diskon | |
<form action="tugas2.php" method="post"> | |
<table> | |
<tr> | |
<td>Nama: </td> | |
<td><input type="text" name="nama"></td> | |
</tr> | |
<tr> | |
<td>NIM</td> | |
<td><input type="text" name="nim"></td> | |
</tr> | |
</table> | |
<hr> | |
<table> | |
<tr> | |
<td>Harga Barang 1: </td> | |
<td><input type="text" name="harga1"></td> | |
</tr> | |
<tr> | |
<td>Harga Barang 2: </td> | |
<td><input type="text" name="harga2"></td> | |
</tr> | |
<tr> | |
<td>Harga Barang 3: </td> | |
<td><input type="text" name="harga3"></td> | |
</tr> | |
<tr> | |
<td><input type="submit" name="hasil" value="total"></td> | |
</tr> | |
</table> | |
<?php | |
if(isset($_POST['hasil'])){ | |
$nama = $_POST['nama']; | |
$nim = $_POST['nim']; | |
$harga1 = $_POST['harga1']; | |
$harga2 = $_POST['harga2']; | |
$harga3 = $_POST['harga3']; | |
$diskon = 0; | |
$a = "0%"; | |
$total = $harga1+$harga2+$harga3; | |
if($total>1000000){ | |
$diskon = 10/100*$total; | |
$a = "10%"; | |
} | |
echo "Nama: ".$nama."<br>NIM: ".$nim."<br>Harga Barang 1: Rp.".number_format($harga1); | |
echo "<br>Harga Barang 2: Rp.".number_format($harga2); | |
echo "<br>Harga Barang 3: Rp.".number_format($harga3); | |
echo "<br>Diskon: ". $a; | |
echo "<br>Total pembayaran: " .number_format($total - $diskon); | |
} | |
?> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment