Langsung saja di copas codingnya gan :D
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
main()
{
int x,i,banyak,total,diskon,bayar,kembali,total_bayar;
int input[10][5];
char pilih,menu,nama[5][5][20];
utama:
clrscr();
cout<<"****************************************"<<endl;
cout<<"-------------Toko Array Kobra-----------"<<endl;
cout<<"****************************************"<<endl;
cout<<"\n";
cout<<"Pilihan Menu :"<<endl;
cout<<"1.Dumolid :150000 4.Martel :400000"<<endl;
cout<<"2.Alfrazolam :130000 5.Cristal :300000"<<endl;
cout<<"3.Calmlate :140000 6.Vodka :350000"<<endl;
cout<<"\n";
cout<<"*****************************************"<<endl;
cout<<"Masukan jumlah barang yang akan di beli : "; cin>>x;
for(i=1; i<=x; i++)
{
cout<<"Pilihan ke- "<<i<<endl;
cout<<"Pilih menu [1/2/3/4/5/6] :"; cin>>menu;
if(menu=='1')
{
input[i][0]=150000;
strcpy(nama[i][0],"Dumolid");
cout<<"Masukan banyak Dumolid yang akan di beli : "; cin>>banyak;
cout<<"\n";
}
else if(menu=='2')
{
input[i][0]=130000;
strcpy(nama[i][0],"Alfrazolam");
cout<<"Masukan banyak Alfrazolam yang akan di beli : "; cin>>banyak;
cout<<"\n";
}
else if(menu=='3')
{
input[i][0]=140000;
strcpy(nama[i][0],"Calmlate");
cout<<"Masukan banyak Calmlate yang akan di beli : "; cin>>banyak;
cout<<"\n";
}
else if(menu=='4')
{
input[i][0]=400000;
strcpy(nama[i][0],"Martel");
cout<<"Masukan banyak Artel yang akan di beli : "; cin>>banyak;
cout<<"\n";
}
else if(menu=='5')
{
input[i][0]=330000;
strcpy(nama[i][0],"Cristal");
cout<<"Masukan banyak cristal yang akan di beli : "; cin>>banyak;
cout<<"\n";
}
else if(menu=='6')
{
input[i][0]=150000;
strcpy(nama[i][0],"Vodka");
cout<<"Masukan banyak Vodka yang akan di beli : "; cin>>banyak;
cout<<"\n";
}
else
{
cout<<"EROR...!!!"<<endl;
}
input[i][1]=input[i][0]*banyak;
input[i][2]=banyak;
}
total=0;
cout<<"****************************************"<<endl;
cout<<"-------------Toko Array Kobra-----------"<<endl;
cout<<"****************************************"<<endl;
cout<<"no jenis barang harga jumlah total harga"<<endl;
for(i=1; i<=x; i++)
{
cout<<i<<" "<<nama[i][0]<<"\t "<<input[i][0]<<" "<<input[i][2]<<"\t "<<input[i][1]<<endl;
total=total+input[i][1];
}
cout<<"\n";
cout<<"total belanjaan : "<<total<<endl;
diskon=(total>500000)*(0.10*total);
cout<<"diskon : "<<diskon<<endl;
total_bayar=total-diskon;
cout<<"total bayar : "<<total_bayar<<endl;
bayar:
cout<<"masukan jumlah uang anda : "; cin>>bayar;
if (bayar<=total_bayar)
{
cout<<"maaf pembayaran anda kurang !"<<endl;
goto bayar;
}
kembali=bayar-total_bayar;
cout<<"kembalian anda :"<<kembali<<endl;
cout<<"********************************************" <<endl;
cout<<"TERIMA KASIH ANDA SUDH BELANJA DI TOKO KAMI :)"<<endl;
cout<<"apakah anda ingin berbelanja kembali ? [y/n] : "; cin>>pilih;
if (pilih=='y')
{
goto utama;
}
else
{
cout<<"terimakasih :) ";
}
getch();
}
//create by : asrul mubarok
0 comments:
Post a Comment