review uas c++ tiket kai
Review uas c++ tiket kai
#include <conio>
#include <iostream>
#include <stdio>
#include <iomanip>
main()
{
int z,jml,jb[15],kd1,kd2,kd3;
char nm[45],kd[10][15],*jurusan[15] ;
long harga[15],totharga[15],totbayar=0;
atas:
cout<<"masukan nama pembeli : ";gets(nm);
cout<<"masukan Jumlah Data : ";cin>>jml;
cout<<"============================="<<endl;
cout<<" PT KAI PURWOKERTO "<<endl;
cout<<"============================="<<endl;
for (z=1;z<=jml;z++)
{
cout<<"Pilih Kode Tiket [JK/BG/YT] : ";cin>>kd[z];
cout<<"Masukan Jumlah Beli : ";cin>>jb[z];
kd1=strcmp(kd[z],"JK");
kd2=strcmp(kd[z],"BG");
kd3=strcmp(kd[z],"YT");
if (kd1==0 || kd1==32)
{
jurusan[z]="Jakarta";
harga[z]=50000;
}
else if (kd2==0 || kd2==32)
{
jurusan[z]="Bandung";
harga[z]=55000;
}
else
{
jurusan[z]="Yogyakarta";
harga[z]=60000;
}
}
cout<<"============================="<<endl;
cout<<"==================================="<<endl;
cout<<" PT KAI PURWOKERTO "<<endl;
cout<<"==================================="<<endl;
cout<<"Nama Pembeli : "<<nm[z]<<endl;
cout<<"---------------------------------------------------------------------"<<endl;
cout<<"No Kode Jurusan Harga Jumlah Beli Total Harga"<<endl;
cout<<"---------------------------------------------------------------------"<<endl;
for (z=1;z<=jml;z++)
{
cout<<setiosflags(ios::left)<<setw(4)<<z;
cout<<setiosflags(ios::left)<<setw(10)<<kd[z];
cout<<setiosflags(ios::left)<<setw(10)<<jurusan[z];
cout<<setiosflags(ios::left)<<setw(10)<<harga[z];
cout<<setiosflags(ios::left)<<setw(4)<<jb[z];
totharga[z]=harga[z]*jb[z];
cout<<setiosflags(ios::left)<<setw(10)<<totharga[z]<<endl;
totbayar=totbayar+totharga[z];
}
cout<<"--------------------------------------------------------------------"<<endl;
cout<<" Total Bayar : "<<totbayar<<endl;
cout<<"Ingin input lagi [Y/T]: ";cin>>lagi;
if (lagi=='Y' || lagi=='y')
goto atas;
else
getch();
}
0 Response to "review uas c++ tiket kai"
Posting Komentar