fork download
  1. <?php
  2. $total_pembelian = 1200000;
  3. $diskon = 0;
  4.  
  5. if ($total_pembelian > 1000000) {
  6. $diskon = 0.10;
  7. } elseif ($total_pembelian > 500000) {
  8. $diskon = 0.05;
  9. } else {
  10. $diskon = 0;
  11. }
  12.  
  13. $jumlah_diskon = $total_pembelian * $diskon;
  14. $total_pembayaran = $total_pembelian - $jumlah_diskon;
  15.  
  16. echo "Total Pembelian: Rp" . number_format($total_pembelian, 0, ',', '.') . "<br>";
  17. echo "Diskon: " . ($diskon * 100) . "%<br>";
  18. echo "Jumlah Diskon: Rp" . number_format($jumlah_diskon, 0, ',', '.') . "<br>";
  19. echo "Total Pembayaran Setelah Diskon: Rp" . number_format($total_pembayaran, 0, ',', '.') . "<br>";
  20. ?>
Success #stdin #stdout 0.03s 25500KB
stdin
Standard input is empty
stdout
Total Pembelian: Rp1.200.000<br>Diskon: 10%<br>Jumlah Diskon: Rp120.000<br>Total Pembayaran Setelah Diskon: Rp1.080.000<br>