Untuk syntaknya :
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
void main()
{
char a,b;
int beli,liter,bayar,kembali,u,jumlah;
long int uang,temp,data[5]={10000,5000,1000,500,100};
up:
clrscr();
cout<<"Beli Bnesin dalam satuan :"<<endl<<endl;
cout<<"1.Satuan Harga"<<endl;
cout<<"2.Satuan Berat"<<endl;
cout<<"Pilihan Anda (1 atau 2) : ";cin>>a;
cout<<endl<<endl;
if (a=='1')
{
clrscr();
cout<<" HARGA "<<endl;
cout<<" (Rp.4500,-/liter) "<<endl;
cout<<"=========================="<<endl;
cout<<"jumlah beli : Rp. ";cin>>beli;
if (beli>4500)
{cout<<"uang bayar : Rp. ";cin>>bayar;
clrscr();
cout<<" BERAT "<<endl;
cout<<"==========================";
liter=beli/4500;
cout<<endl<<" "<<liter<<" LITER";
cout<<endl<<"==========================";
kembali=bayar-beli;
cout<<endl<<"Uang Kembali : Rp. "<<kembali;
cout<<endl<<"--------------------------"<<endl;}
else
{
clrscr();cout<<"Maaf, pembelian BENSIN minimal Rp.4500,-"<<endl;
getch();goto up;
}
}
else if (a=='2')
{
clrscr();
cout<<" PERTAMAX "<<endl;
cout<<" (Rp.6800,-/liter) "<<endl;
cout<<"========================="<<endl;
cout<<"jumlah beli : Rp. ";cin>>beli;
cout<<"uang bayar : Rp. ";cin>>bayar;
clrscr();
cout<<" PERTAMAX "<<endl;
cout<<"=========================";
liter=beli/6800;
cout<<endl<<" "<<liter<<" LITER";
cout<<endl<<"=========================";
kembali=bayar-beli;
cout<<endl<<"Uang Kembali : Rp. "<<kembali;
cout<<endl<<"-------------------------"<<endl;
}
else if (a=='3')
{
clrscr();
cout<<" SOLAR "<<endl;
cout<<" (Rp.4000,-/liter) "<<endl;
cout<<"========================="<<endl;
cout<<"jumlah beli : Rp. ";cin>>beli;
cout<<"uang bayar : Rp. ";cin>>bayar;
clrscr();
cout<<" SOLAR "<<endl;
cout<<"=========================";
liter=beli/4000;
cout<<endl<<" "<<liter<<" LITER";
cout<<endl<<"=========================";
kembali=bayar-beli;
cout<<endl<<"Uang Kembali : Rp. "<<kembali;
cout<<endl<<"-------------------------"<<endl;
}
else
{clrscr();
cout<<endl<<"Pilihan SALAH."<<endl;getch();goto down;}
uang=kembali;
temp=uang;
cout<<endl<<"Rincian kembalian = ";
for(u=0;u<=4;u++)
{
jumlah = temp / data[u];
temp = temp - (data[u]*jumlah);
printf("\n%d) %li : %d",u,data[u],jumlah);
}
cout<<endl<<"=========================";
down:
cout<<endl<<endl<<"ingin mengulangi kembali?\n(y/t) ";cin>>b;
cout<<endl;
if(b=='y')
{clrscr();goto up;}
else
{
goto exit;
}
exit:
}
Ini hasilnya. ::
0 comments:
Post a Comment