Thursday, 18 June 2020

Program Daftar Belanja

#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <iomanip>
using namespace std;
int main()
{
    string nama[25], tanggal[10], nama_brng[25], ket[25];
    int jml_belanja[10], jml_beli[10], hrg_satuan[25],jml_harga[25],total[25],total_byr[25];
    int i,j,n;

cout<<"Masukan Nama = ";cin>>nama[i];
cout<<"Masukan Tanggal = ";cin>>tanggal[i];
cout<<"Masukan Jumlah Belanja = ";cin>>jml_belanja[i];

for (i=1;i<=n;i++)
{
   
    cout<<"Masukan Nama Barang = ";cin>>nama_brng[i];
    cout<<"Masukan Jumlah Beli = ";cin>>jml_beli[i];
    cout<<"Masukan Harga Satuan = ";cin>>hrg_satuan[i];
       
    jml_harga[i]=jml_beli[i]*hrg_satuan[i];
    total[i]=jml_beli[i]*jml_harga[i];   

if (total[i]>=300000)
{
    total_byr[i]=total[i]*35/100;
    ket[i]="Dapat Diskon 35%";
}
else   
if (total[i]>=100000 && total[i]<300000)
{
    total_byr[i]=total[i]*25/100;
    ket[i]="Dapat Diskon 25%";
}
else       
if (total[i]>=50000 && total[i]<100000)
{
    total_byr[i]=total[i]*10/100;
    ket[i]="Dapat Diskon 10%";
}
else
{
    ket[i]="Tidak Mendapatkan Diskon";   
}

}   
    cout<<"                                DAFTAR BELANJA ANDA"<<endl;   
    cout<<endl;          
    cout<<" Nama Anda = "<<nama[i]<<endl;
    cout<<" Tanggal = "<<tanggal[i]<<endl;
    cout<<" Jumlah Belanja ="<<jml_belanja[i]<<endl;
    cout<<endl;  
cout<<"--------------------------------------------------------------------------------------------------------------------------------------------------------------"<<endl;
cout<<"|     Nama Barang     |     Jumlah Beli     |     Harga Satuan     |     Jumlah Harga     |        Total        |      Keterangan      |     Total Bayar     |"<<endl;
cout<<"--------------------------------------------------------------------------------------------------------------------------------------------------------------"<<endl;

for (i=1;i<=jml_belanja[i];i++)
      {
        cout<<"|"<<setw(21);cout<<nama_brng[i];
        cout<<"|"<<setw(21);cout<<jml_beli[i];  
        cout<<"|"<<setw(22);cout<<hrg_satuan[i];  
        cout<<"|"<<setw(22);cout<<jml_harga[i];
        cout<<"|"<<setw(21);cout<<total[i];
        cout<<"|"<<setw(22);cout<<ket[i];
        cout<<"|"<<setw(21);cout<<total_byr[i];
        cout<<"|"<<endl;
cout<<"--------------------------------------------------------------------------------------------------------------------------------------------------------------"<<endl;
              
      }  

       
    return 0;
}

No comments:

Post a Comment