#include<iostream>
#include<iomanip>
using namespace std;
int main ()
{
int qty;//untuk melalakukan pengulangan banyak inputan
char jenis[20] = {'d','D','p','P','s','S'};
int harga_satuan[100],banyak_beli[100],jumlah_harga[100],total_bayar;
int jumlah_bayar=0;
float pajak,diskon;
cout<< "KAMPUS FRIED CHICKEN (KFC)"<<endl;
cout<< "--------------------------"<<endl;
cout<< "KODE JENIS HARGA "<<endl;
cout<< "--------------------------"<<endl;
cout<< " D DADA Rp.2500 "<<endl;
cout<< " p PAHA Rp.2000 "<<endl;
cout<< " s SAYAP Rp.1500 "<<endl;
cout<< "--------------------------"<<endl;
cout<< "Inputkan Jumlah Beli : "; cin>>qty;
for(int i=1; i<=qty; i++)
{
cout<< "Jenis ke- "<<i<<endl;
cout<< "Jenis Potong (D/P/S) : "; cin>>jenis[i];
cout<< "Banyak Potong : "; cin>>banyak_beli[i];
cout<<endl;
//proses rumus
if(jenis[i]== 'D' || jenis[i]== 'd')
{
harga_satuan[i]=2500;
}
else if(jenis[i]== 'P' || jenis[i]== 'p')
{
harga_satuan[i]=2000;
}
else if(jenis[i]=='S' || jenis[i]=='s')
{
harga_satuan[i]=1500;
}
else
{
cout<< "Maaf Jenis Yang Anda Pilih Belum Tersedia";
return 0;
}
jumlah_harga[i]=banyak_beli[i]*harga_satuan[i];
}
//menampilkan array
cout<< "KAMPUS FRIED CHICKEN"<<endl;
cout<< "--------------------------------------"<<endl;
cout<< "NO Jenis Harga Banyak Jumlah"<<endl;
cout<< " Potong Satuan Beli "<<endl;
cout<< "--------------------------------------"<<endl;
for(int i=1; i<=qty; i++)
{
cout<<setiosflags(ios::left)<<setw(6)<<i;
cout<<setiosflags(ios::left)<<setw(8)<<jenis[i];
cout<<setiosflags(ios::left)<<setw(10)<<harga_satuan[i];
cout<<setiosflags(ios::left)<<setw(10)<<banyak_beli[i];
cout<<jumlah_harga[i];
cout<<endl;
//rumus spesial array
jumlah_bayar=jumlah_bayar+jumlah_harga[i];
diskon=jumlah_bayar*0.05;
pajak=jumlah_bayar*0.1;
total_bayar=jumlah_bayar+pajak-diskon;
}
cout<< "--------------------------------------" <<endl;
cout<< " Jumlah Bayar = "<<jumlah_bayar<<endl;
cout<< " Diskon 5% = "<<diskon <<endl;
cout<< " Pajak 10% = "<<pajak <<endl;
cout<< " Total Bayar = "<<total_bayar <<endl;
return 0;
}
Comments
Post a Comment