Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- char jenis;
- string diskon;
- int kode, harga, stlDiskon; //stlDiskon = harga setelah didiskon(setelah diskon)
- cout << "Masukkan jenis barang: ";
- cin >> jenis;
- cout << "Masukkan kode: ";
- cin >> kode;
- cout << "Masukkan harga barang: ";
- cin >> harga;
- // menentukan diskon
- switch(jenis){
- case 'A': case 'a':
- diskon = "10%";
- stlDiskon = harga-(10*harga/100);
- break;
- case 'B': case 'b':
- diskon = "15%";
- stlDiskon = harga-(15*harga/100);
- break;
- case 'C': case 'c':
- diskon = "20%";
- stlDiskon = harga-(20*harga/100);
- break;
- default:
- diskon = "tidak ada";
- stlDiskon = 999999999;
- }
- cout << "Jenis barang " << jenis
- << " mendapat diskon = " << diskon << ", harga setelah didiskon = " << stlDiskon;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement