#include <iostream>
#include <string.h>
using namespace std;
//Function NOT Return Value (Without Parameter)
void garis() {
puts("--------------------------------------------------");
}
//Function NOT Return Value (Without Parameter)
void ttd() {
cout<<"Nama : Irsyad Purbha"<<endl;
cout<<"Email : irsyadpurbha.fst@uia.ac.id"<<endl;
}
//Function NOT Return Value (Without Parameter)
void judul() {
garis();
cout<<"Toko Buku Almara"<<endl;
cout<<"Jatiasih - Bekasi"<<endl;
garis();
}
//Function Return Value (With Parameter)
string cek_nama(char kode) {
//Struktur Switch Case
switch (kode) {
case '1':
return "Sukses Belajar C++";
break;
case '2':
return "Kunci Pribadi Yang Sukses";
break;
case '3':
return "Mencari Mutiara Di Dasar Hati";
break;
default:
return "";
}
}
//Function Return Value (With Parameter)
float cek_harga(char kode) {
switch (kode) {
case '1':
return 50000;
break;
case '2':
return 35000;
break;
case '3':
return 45000;
break;
default:
return 0;
}
}
void cek_bonus(int jml) {
//Struktur IF
if(jml > 5) {
cout<<"Bonus : Kotak Pensil"<<endl;
} else {
cout<<"Bonus : Maaf Tidak Dapat Bonus"<<endl;
}
}
//Function Return Value (Without Parameter)
int main() {
judul();
cout<<"KETENTUAN"<<endl;
garis();
cout<<"| Kode | Judul | Harga |"<<endl;
garis();
cout<<"| 1 | Sukses Belajar C++ | 50.000 |"<<endl;
cout<<"| 2 | Kunci Pribadi Yang Sukses | 35.000 |"<<endl;
cout<<"| 3 | Mencari Mutiara Di Dasar Hati | 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% ";
cout<<"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();
char kode;
string nama;
int jml;
float harga, subtotal, pot, ppn, total;
printf("Masukan kode buku [1/2/3]: <input>"); cin>>kode; cout<<endl;
printf("Jumlah pembelian buku : <input>"); scanf("%d",&jml); cout<<endl;
nama = cek_nama(kode);
harga = cek_harga(kode);
subtotal = harga * jml;
ppn = 0.1 * subtotal;
//Struktur IF
if(jml > 5) {
pot = 0.1 * subtotal;
} else {
pot = 0;
}
total = subtotal + ppn - pot;
garis();
cout<<"Nama Buku : "<<nama<<endl;
cout<<"Harga Buku : "<<harga<<endl;
cek_bonus(jml);
printf("Subtotal : Rp. %0.2f\n",subtotal);
printf("Potongan : Rp. %0.2f\n",pot);
printf("PPN : Rp. %0.2f\n",ppn);
printf("Total : Rp. %0.2f\n",total);
garis();
puts("Terima Kasih");
garis();
ttd();
return 0;
}