#include<conio.h>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main() {
int n,i;
string nama_toko, alamat, website,ket[20], nama_brg[20];
int hrg_brg[20],jml_brg[20],total[20],diskon[20],bayar[20];
long long no_hp;
cout << "Masukan Nama toko : ";getline(cin, nama_toko);
cout << "Masukan Alamat: ";getline(cin, alamat);
cout << "Masukan no_hp : ";cin >> no_hp;
cout << "Masukan Website: ";cin >> website;
cout << "Masukan jumlah barang : ";cin >> n;
for (i = 0; i < n; i++)
{
cout << "Data Ke- " << i+1 <<endl;
cout << "nama barang: "; cin.ignore();getline(cin,nama_brg[i]);
cout << "harga barang : ";cin>>hrg_brg[i];
cout << "beli berapa banyak : ";cin>>jml_brg[i];
cout << endl;
total[i] = hrg_brg[i] * jml_brg[i];
if (total[i]>5000000)
{
diskon[i]=total[i]*0.5;
ket[i] = "Dapat diskon 50%";
}
else if (total[i]>3000000)
{
diskon[i]=total[i]*0.3;
ket[i] = "Dapat diskon 30%";
}
else if (total[i]>2000000)
{
diskon[i]=total[i]*0.2;
ket[i] = "Dapat diskon 20%";
}
else if (total[i]>1000000)
{
diskon[i]=total[i]*0.1;
ket[i] = "Dapat diskon 10%";
}
else{
diskon[i]= 0;
ket[i] = "tidak dpt diskon";
}
bayar[i]=total[i]-diskon[i];
}
system("cls");
cout<<" Nama Toko : "<<nama_toko<<endl;
cout<<" Alamat : "<<alamat<<endl;
cout<<" Website : "<<website<<endl;
cout<<" No HP : "<<no_hp<<endl;
cout << "=================================================================================================" << endl;
cout<<setiosflags(ios::left)<<setw(5)<<"No";
cout<<setw(15)<<"Nama Barang";
cout<<setw(18)<<"Harga Satuan";
cout<<setw(15)<<"Jumlah Barang";
cout<<setw(9)<<"Total";
cout<<setw(9)<<"Diskon";
cout<<setw(18)<<"Keterangan";
cout<<setw(18)<<"Bayar"<<endl;
cout << "=================================================================================================" << endl;
for (i = 0; i < n; i++)
{
cout << setiosflags(ios::left) << setw(5) << i + 1;
cout << setw(15) << nama_brg[i];
cout << setw(18) << hrg_brg[i];
cout <<setprecision(2)<<setw(15) << jml_brg[i];
cout <<setprecision(2)<<setw(9) << total[i];
cout <<setprecision(2)<< setw(9) << diskon[i];
cout << setw(18) << ket[i];
cout <<setprecision(2)<< setw(18) << bayar[i];
cout<<endl;
}
cout << "=================================================================================================" << endl;
}
No comments:
Post a Comment