<?php
// variabel total pembelian
$totalPembelian = 700000;
// diskon
if ($totalPembelian > 1000000) {
$diskon = 0.10; // 10%
} elseif ($totalPembelian > 500000) {
$diskon = 0.05; // 5%
} else {
$diskon = 0; // Tidak ada diskon
}
// total diskon dan total pembayaran
$jumlahDiskon = $totalPembelian * $diskon;
$totalPembayaran = $totalPembelian - $jumlahDiskon;
// hasil perhitungan
echo "Total Pembelian: Rp " . ($totalPembelian) . "\n";
echo "Diskon: " . ($diskon * 100) . "% (Rp " . ($jumlahDiskon) . ")\n";
echo "Total Pembayaran: Rp " .($totalPembayaran);
?>
PD9waHAKCi8vIHZhcmlhYmVsIHRvdGFsIHBlbWJlbGlhbgoJJHRvdGFsUGVtYmVsaWFuID0gNzAwMDAwOyAKCi8vIGRpc2tvbgppZiAoJHRvdGFsUGVtYmVsaWFuID4gMTAwMDAwMCkgewogICAgJGRpc2tvbiA9IDAuMTA7IC8vIDEwJQp9IGVsc2VpZiAoJHRvdGFsUGVtYmVsaWFuID4gNTAwMDAwKSB7CiAgICAkZGlza29uID0gMC4wNTsgLy8gNSUKfSBlbHNlIHsKICAgICRkaXNrb24gPSAwOyAvLyBUaWRhayBhZGEgZGlza29uCn0KCi8vIHRvdGFsIGRpc2tvbiBkYW4gdG90YWwgcGVtYmF5YXJhbgoJJGp1bWxhaERpc2tvbiA9ICR0b3RhbFBlbWJlbGlhbiAqICRkaXNrb247CgkkdG90YWxQZW1iYXlhcmFuID0gJHRvdGFsUGVtYmVsaWFuIC0gJGp1bWxhaERpc2tvbjsKCi8vIGhhc2lsIHBlcmhpdHVuZ2FuCgllY2hvICJUb3RhbCBQZW1iZWxpYW46IFJwICIgLiAoJHRvdGFsUGVtYmVsaWFuKSAuICJcbiI7CgllY2hvICJEaXNrb246ICIgLiAoJGRpc2tvbiAqIDEwMCkgLiAiJSAoUnAgIiAuICgkanVtbGFoRGlza29uKSAuICIpXG4iOwoJZWNobyAiVG90YWwgUGVtYmF5YXJhbjogUnAgIiAuKCR0b3RhbFBlbWJheWFyYW4pOwoKPz4=