Advertisement
amrulHarahap

Program Menentukan Diskon Barang-1

Nov 28th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 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.             break;
  23.         case 'B': case 'b':
  24.             diskon = "15%";
  25.             stlDiskon = harga-(15*harga/100);
  26.             break;
  27.         case 'C': case 'c':
  28.             diskon = "20%";
  29.             stlDiskon = harga-(20*harga/100);
  30.             break;
  31.         default:
  32.             diskon = "tidak ada";
  33.             stlDiskon = 999999999;
  34.     }
  35.  
  36.  
  37.     cout << "Jenis barang " << jenis
  38.         << " mendapat diskon = " << diskon << ", harga setelah didiskon = " << stlDiskon;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement