Total Belanjan

Posted: 1 Juli 2013 in Praktikum Alpro

Source C++ :

#include <cstdlib>
#include <iostream>

using namespace std;

class versiA{
friend istream& operator>>(istream&, versiA);
public:
versiA(){cout<<“Program menghitung total harga belanja”<<endl;)
void proses();

private:
int total, n, pil, jum, bayar;
};
istream& operator>>(istream& in, versiA& x){
for (int i=0; i<n; i++){
cout<<“Masukan pilihan :”;
cin>>pil;
cout<<“masukan banyak barang:”;
cin>>jum;
total+=harga[pil-1]*jum;
}
cout<<“Total semua item =”<<total<<endl;
cout<><“Jumlah bayar =”;
cin>>bayar;
cout<<“kembalian=”<<bayar-total<<endl;
if(total>=50000 && total<100000{
bayar=bayar-total+(total*5/100);
}
if(total>100000){
bayar=bayar-total+(total*10/100);
cout<<“Total yang dibayarkan”<<endl;
//di isi
}
void versiA::proses(){
string produk(5)=(“sabun mandi”,”minyak goreng”,”mie instan”,”pewangi”,”sayur mayur”);
int harga[5]=(2500,12000,2000,15000,2000);
cout<<“Nama barang \tharga “<<endl;
cout<<“====================”<<endl;
for (int i=0; i<5; i++){
cout<<i+1<<“.”<<produk[i]<<“\t\t”<<harga[i]<<endl;
}
}
}
int main (int argc, char *argv[])
{
versiA x;
cin>>x;
x.proses();
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