#include <iostream>
#include <conio>
#include <iomanip>
main()
{
char nama_barang[20];
int jml_beli,jml_barang,i;
float diskon, total_pembayaran,harga,total_harga,total_bayar;
cout<<"masukkan jumlah barang="; cin>>jml_barang;
i=1;
total_bayar=0;
while(i<=jml_barang)
{
cout<<endl;
cout<<"Masukkan nama barang : "; cin>>nama_barang;
cout<<"Masukkan jumlah beli: "; cin>>jml_beli;
cout<<"Masukkan harga barang : "; cin>>harga;
total_harga=jml_beli*harga;
total_bayar=total_bayar+total_harga;
i++;
}
if (total_bayar>500000)
diskon=0.05*total_bayar;
else
diskon=0;
total_pembayaran=total_bayar-diskon;
cout<<endl;
cout<<"Total bayar : "<<total_bayar;
cout<<"\ndiskon : "<<diskon;
cout<<"\ntotal pembayaran : "<<setiosflags(ios::fixed)<<setprecision(2)<<total_pembayaran;
getch();
}
#include <conio>
#include <iomanip>
main()
{
char nama_barang[20];
int jml_beli,jml_barang,i;
float diskon, total_pembayaran,harga,total_harga,total_bayar;
cout<<"masukkan jumlah barang="; cin>>jml_barang;
i=1;
total_bayar=0;
while(i<=jml_barang)
{
cout<<endl;
cout<<"Masukkan nama barang : "; cin>>nama_barang;
cout<<"Masukkan jumlah beli: "; cin>>jml_beli;
cout<<"Masukkan harga barang : "; cin>>harga;
total_harga=jml_beli*harga;
total_bayar=total_bayar+total_harga;
i++;
}
if (total_bayar>500000)
diskon=0.05*total_bayar;
else
diskon=0;
total_pembayaran=total_bayar-diskon;
cout<<endl;
cout<<"Total bayar : "<<total_bayar;
cout<<"\ndiskon : "<<diskon;
cout<<"\ntotal pembayaran : "<<setiosflags(ios::fixed)<<setprecision(2)<<total_pembayaran;
getch();
}
Post a Comment