#include <iostream>
using namespace std;
int main()
{
cout << "** Program Belanja C++ **" << endl;
cout << "=========================================" << endl;
cout << endl;
int total_belanja, harga_akhir, jumlah_barang, harga_barang;
string nama_barang;
//input data belanja
cout<<" Masukan Nama barang : "; getline(cin,nama_barang);
cout<<" Masukan Harga barang : ";cin>>harga_barang;
cout<<" Masukan Jumlah barang : ";cin>>jumlah_barang;
cout << "=========================================" << endl;
//Proses hitung total belaja
cout << "Total Belanja: Rp.";
total_belanja=harga_barang * jumlah_barang;
cout<<total_belanja;
cout << endl;
cout << "======Kondisi potongan harga ============" << endl;
//menentukan kondisi belanja untuk menentukan potongan
if ((total_belanja >= 100000) && (total_belanja < 500000)) {
harga_akhir = total_belanja - (0.1*total_belanja);
cout << "Selamat, anda mendapat diskon 10%" << endl;
}
else if ((total_belanja >= 500000) && (total_belanja < 1000000)) {
harga_akhir = total_belanja - (0.2*total_belanja);
cout << "Selamat, anda mendapat diskon 20%" << endl;
}
else if (total_belanja >= 1000000) {
harga_akhir = total_belanja - (0.3*total_belanja);
cout << "Selamat, anda mendapat diskon 30%" << endl;
}
else {
harga_akhir = total_belanja;
}
cout << "=============Output=====================" << endl;
//output belanja
cout<<"Nama Barang belanja adalah: "<<nama_barang <<" dangan Jumlah : "<<jumlah_barang<<endl;
cout <<"Total bayar: Rp." << harga_akhir << endl;
return 0;
}
No comments:
Post a Comment