Menghitung diskon

Posted: 1 Juli 2013 in Praktikum Alpro

Source C++ :

#include <cstdlib>
#include <iostream>

using namespace std;
class diskon{
public:
diskon(){cout<<“menghitung diskon”<<endl;}
void hitung();
private:
int total, item, n, pil;
};
void diskon::hitung(){
string produk[5] = {“Inzana”,”Morfin”,”Acetosal”,”Kuinin”,”Insulin”};
int harga[5] = {5000,10000,7500,8500,12500};
total=0;
for(int i=0; i<5; i++){
cout<<i+1<<“. “<<produk[i]<<“\t\t”<<harga[i]<<endl;
}
cout<<“masukin jumlah item yang di beli :”; cin>>item;
for(int i=0; i<item;i++){
cout<<“masukin pilihan :”; cin>>pil;
cout<<“masukin jumlah barang :”; cin>>n;
total += harga[pil-1]*n;
cout<<produk[pil-1]<<” jumlah “<<n<<endl;
}
cout<<“total harga :”<<total<<endl;
if (total>50000 && total<=100000){
total = total – (total*5/100);
}
if (total>100000 && total<=200000){
total = total – (total*10/100);
}
if (total>200000){
total = total – (total*15/100);
}
cout<<“total harga yang di bayarkan:”<<total<<endl;
}
int main(int argc, char *argv[])
{
diskon x;
x.hitung();
system(“PAUSE”);
return EXIT_SUCCESS;
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s