fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int bulan = 3;
  6. int tabungan;
  7. int total = 0;
  8. int bonus = 0;
  9.  
  10. for (int i = 1; i <= bulan; i++) {
  11. if (i == 1)
  12. tabungan = 400000;
  13. else if (i == 2)
  14. tabungan = 300000;
  15. else
  16. tabungan = 500000;
  17.  
  18. cout << "Tabungan bulan ke-" << i << " = Rp" << tabungan << endl;
  19. total += tabungan;
  20.  
  21. }
  22. if (total >= 1000000) {
  23. bonus = total * 5 / 100;
  24. }
  25. cout << "\nTotal tabungan = Rp" << total << endl;
  26. cout << " Bouns = Rp" << bonus << endl;
  27. cout << "Total akhir = Rp" << total + bonus << endl;
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Tabungan bulan ke-1 = Rp400000
Tabungan bulan ke-2 = Rp300000
Tabungan bulan ke-3 = Rp500000

Total tabungan = Rp1200000
 Bouns = Rp60000
Total akhir = Rp1260000