Ya sekali-kali posting yg berbau materi biar kayak anak kuliahan tea, alih-alih belajar buat UAS malah jadi program yg lumayan deh buat ngasah otak yg ngga tajem-tajem ini.
Yuk yuk yuk langsung aja yaaa....
#include
#include
#include
#include
char kd[5], *nmtkt[5];
long hrg[5], ttl[5], ubay, ukem, grandtotal;
int jml[5], x, y;
nama()
{
if
((kd[x]=='a')||(kd[x]=='A'))
{
nmtkt[x]="Senja Utama Yogya";
hrg[x]=200000;
}
else if
((kd[x]=='b')||(kd[x]=='B'))
{
nmtkt[x]="GBM Selatan";
hrg[x]=33500;
}
else if
((kd[x]=='c')||(kd[x]=='C'))
{
nmtkt[x]="KutoJaya Utara";
hrg[x]=28000;
}
else if
((kd[x]=='d')||(kd[x]=='D'))
{
nmtkt[x]="Bangunkarta";
hrg[x]=280000;
}
else if
((kd[x]=='e')||(kd[x]=='E'))
{
nmtkt[x]="Kertajaya";
hrg[x]=41500;
}
}
pembayaran()
{
ttl[x]=jml[x]*hrg[x];
}
main()
{
clrscr();
cout<<"*******************************************************************"<cout<<" Loket Pemesanan Tiket Kereta Api"<cout<<" Stasiun Pasar Senen (PSE)"<cout<<"*******************************************************************"<cout<<"Masukan Jumlah Data:";cin>>y;
for(x=1;x<=y;x++)
{
cout<<"Kode Kereta Api:";cin>>kd[x];
cout<<"Jumlah Beli :";cin>>jml[x];
cout<<" "<cout<<" "<
nama();
pembayaran();
}
cout<
cout<<"=============================================================================="<cout<<" Struk Pemesanan Tiket Kereta Api"<cout<<" Stasiun Pasar Senen (PSE)"<cout<<"NO KODE NAMA KERETA HARGA JUMLAH TOTAL "<cout<<"=============================================================================="<for(x=1;x<=y;x++)
{
cout<cout<cout<cout<cout<cout<
cout<
cout<grandtotal=grandtotal+ttl[x];
}
cout<<"Total Bayar:"<cout<cout<<"Uang Bayar :";cin>>ubay;
ukem=ubay-grandtotal;
cout<<"Uang Kembali:"<getch();
}
Selamat mencoba.
Yuk yuk yuk langsung aja yaaa....
#include
#include
#include
#include
char kd[5], *nmtkt[5];
long hrg[5], ttl[5], ubay, ukem, grandtotal;
int jml[5], x, y;
nama()
{
if
((kd[x]=='a')||(kd[x]=='A'))
{
nmtkt[x]="Senja Utama Yogya";
hrg[x]=200000;
}
else if
((kd[x]=='b')||(kd[x]=='B'))
{
nmtkt[x]="GBM Selatan";
hrg[x]=33500;
}
else if
((kd[x]=='c')||(kd[x]=='C'))
{
nmtkt[x]="KutoJaya Utara";
hrg[x]=28000;
}
else if
((kd[x]=='d')||(kd[x]=='D'))
{
nmtkt[x]="Bangunkarta";
hrg[x]=280000;
}
else if
((kd[x]=='e')||(kd[x]=='E'))
{
nmtkt[x]="Kertajaya";
hrg[x]=41500;
}
}
pembayaran()
{
ttl[x]=jml[x]*hrg[x];
}
main()
{
clrscr();
cout<<"*******************************************************************"<
for(x=1;x<=y;x++)
{
cout<<"Kode Kereta Api:";cin>>kd[x];
cout<<"Jumlah Beli :";cin>>jml[x];
cout<<" "<
nama();
pembayaran();
}
cout<
cout<<"=============================================================================="<
{
cout<
cout<
cout<
}
cout<<"Total Bayar:"<
ukem=ubay-grandtotal;
cout<<"Uang Kembali:"<
}
Selamat mencoba.
syiiiiiiiiiiip...
BalasHapuscemunguuuuuudh yaaak kuliahnya :)