Advertisement
amrulHarahap

Program Menentukan Diskon Barang-2

Nov 28th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.     char jenis;
  6.     string diskon;
  7.     int kode, harga, stlDiskon; //stlDiskon = harga setelah didiskon(setelah diskon)
  8.    
  9.     cout << "Masukkan jenis barang: ";
  10.     cin >> jenis;
  11.     cout << "Masukkan kode: ";
  12.     cin >> kode;
  13.     cout << "Masukkan harga barang: ";
  14.     cin >> harga;
  15.  
  16.  
  17.     // menentukan diskon
  18.     switch(jenis){
  19.         case 'A': case 'a':
  20.             diskon = "10%";
  21.             stlDiskon = harga-(10*harga/100);
  22.             cout << "Jenis barang " << jenis << " mendapat diskon " << diskon
  23.             << ", harga setelah didiskon adalah = " << stlDiskon;
  24.             break;
  25.         case 'B': case 'b':
  26.             diskon = "15%";
  27.             stlDiskon = harga-(15*harga/100);
  28.             cout << "Jenis barang " << jenis << " mendapat diskon " << diskon
  29.             << ", harga setelah didiskon adalah = " << stlDiskon;
  30.             break;
  31.         case 'C': case 'c':
  32.             diskon = "20%";
  33.             stlDiskon = harga-(20*harga/100);
  34.             cout << "Jenis barang " << jenis << " mendapat diskon " << diskon
  35.             << ", harga setelah didiskon adalah = " << stlDiskon;
  36.             break;
  37.         default:
  38.             cout << "Maaf, diskon untuk jenis barang " << jenis << " tidak tersedia. Terimakasih";
  39.     }
  40. }
  41. //source code by: A.M.H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement