Tugas11.1.

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <string.h> #include <cstdio> using namespace std; //Function NOT Return Value (Without Parameter) void garis() { puts("---------------------------------------------------------"); } //Function NOT Return Value (Without Parameter) void ttd() { cout<<"Nama : Nur Izzati Istiqlal"<<endl; cout<<"Email : nurizzatisql@gmail.com"<<endl; } //Function NOT Return Value (Without Parameter) void judul(){ cout<<"Toko Buku Sejahtera"<<endl; cout<<"Jatiasih - Bekasi"<<endl; garis(); } //Function Return Value (With Parameter) float hitungPPN() { return 0.1; } //Function Return Value (With Parameter) float hitungPotongan (float subtotal) { return 0.1 * subtotal; } //Function NOT Return Value (With Parameter) void tampilkanBonus (int jmlh, char bonus[]) { if (jmlh > 5) { strcpy(bonus, "Kotak Pensil"); } else { strcpy(bonus, "Maaf Tidak Dapat Bonus"); } } int main () { char kode, nama[30], bonus[30]; int jmlh; float harga = 0, subtotal = 0, potongan = 0, ppn = 0, total = 0; garis(); judul(); cout<<"KETENTUAN"<<endl; garis(); cout<<"| Kode | Judul\t\t\t\t| Harga |"<<endl; garis(); cout<<"| 1 | KKPK (Jangan Takut Gelap)\t| 50.000 |"<<endl; cout<<"| 2 | Sukses UTBK \t\t\t| 35.000 |"<<endl; cout<<"| 3 | Why? (Sporis Science)\t\t| 45.000 |"<<endl; garis(); cout<<"Subtotal = Harga x Jumlah Beli"<<endl; cout<<"PPN = 10% x Subtotal"<<endl; cout<<"Jika jumlah beli lebih dari 5 maka mendapat discount 10% dan bonus kotak pensil."<<endl; garis(); puts("Harus Terdapat Fungsi:"); puts("cout, cin, printf, scanf, puts"); puts("Struktur IF dan Switch Case"); puts("Function Return Value (Without Parameter)"); puts("Function Return Value (With Parameter)"); puts("Function NOT Return Value (Without Parameter)"); puts("Function NOT Return Value (With Parameter)"); garis(); //Input data printf("Masukan kode buku [1/2/3] : <input>\n"); scanf("%c",&kode); cout<<"Jumlah pembelian buku : <input>\n"; cin>>jmlh; //Struktur Switch Case switch (kode) { case '1': strcpy(nama, "KKPK (Jangan Takut Gelap)"); harga = 50000; break; case '2': strcpy(nama, "Sukses UTBK"); harga = 35000; break; case '3': strcpy(nama, "Why? (Sporis Science)"); harga = 45000; break; default: cout << "Kode buku tidak valid!\n"; return 0; } //Hitung subtotal subtotal = harga * jmlh; //Hitung PPN ppn = hitungPPN() * subtotal; //Struktur IF if (jmlh > 5) { potongan = hitungPotongan(subtotal); } else { potongan = 0; } tampilkanBonus(jmlh, bonus); total = subtotal + ppn - potongan; garis(); cout<<"Nama Buku : "<<nama<<endl; cout<<"Harga Buku : "<<harga<<endl; cout<<"Bonus : "<<bonus<<endl; printf("Subtotal : Rp. %0.2f\n",subtotal); printf("Potongan : Rp. %0.2f\n",potongan); printf("PPN : Rp. %0.2f\n",ppn); printf("Total : Rp. %0.2f\n",total); garis(); cout<<"Terima Kasih\n"; garis(); ttd(); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines