Kasus
Array
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
garis()
{cout<<"\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"<<endl;}
main()
{
char siswa[15], kk[4], nmk[30], pass[10];
int i,n,tobay=0;
struct{
char kd[5], kw, wk[20], mt[20];
int biaya1, biaya2, total;
}kursus[20];
atas:
clrscr();
cout<<"\t\t *** RUANG KARYAWAN
***"<<endl;
garis();
cout<<"\t Input Kode Kasir :
";cin>>kk;
cout<<"\t Password : ";cin>>pass;
if(strcmp(kk,"ksr1")==0||strcmp(kk,"KSR1")==0&&strcmp(pass,"123456")==0)
{strcpy(nmk,"Andy");
goto transaksi;}
else
if(strcmp(kk,"ksr2")==0||strcmp(kk,"KSR2")==0&&strcmp(pass,"654321")==0)
{strcpy(nmk,"Budy");
goto transaksi;}
else
{cout<<"SALAH KODE / PASSWORD
KASIR"<<endl;
getch();
goto atas;}
transaksi:
clrscr();
cout<<"\t\t LPK \"Global
Network\""<<endl;
garis();
cout<<"\t Kasir : "<<nmk<<endl;
cout<<"\t Masukan Nama Siswa : ";cin>>siswa;
cout<<"\t Input Jumlah Kursus: ";cin>>n;
garis();
cout<<"\t Inputan Kursus: \n"<<endl;
garis();
cout<<"|KK |Materi |Biaya 1 |Kw
|Waktu |Biaya 2 |"<<endl;
garis();
cout<<"MT01 |Visual |Rp. 120.000 |A
|Pagi |Rp. 75.000 |\n"<<endl;
cout<<" |Basic 6.0 |"<<endl;
cout<<"MT02 |Visual |Rp. 150.000 |B
|sore |Rp. 75.000 |\n"<<endl;
cout<<" |Foxpro 9.0 |"<<endl;
cout<<"MT03 |Internet |Rp. 170.000
|=============================|"<<endl;
garis();
for(i=1;i<=n;i++)
{
cout<<"Data Ke -
"<<i<<endl;
x:
cout<<"Input Kode Kursus :
";cin>>kursus[i].kd;
y:
cout<<"Input Waktu Kursus:
";cin>>kursus[i].kw;
cout<<endl;
if(strcmp(kursus[i].kd,"MT01")==0||strcmp(kursus[i].kd,"mt01")==0)
{strcpy(kursus[i].mt,"Visual Basic 6.0");
kursus[i].biaya1=120000;}
else if(strcmp(kursus[i].kd,"MT02")==0||strcmp(kursus[i].kd,"mt02")==0)
{strcpy(kursus[i].mt,"Visual Foxpro 9.0");
kursus[i].biaya1=150000;}
else
if(strcmp(kursus[i].kd,"MT03")==0||strcmp(kursus[i].kd,"mt03")==0)
{strcpy(kursus[i].mt,"Internet");
kursus[i].biaya1=170000;}
else
{cout<<"Salah Masukan
Kode"<<endl;
getch();
goto x;}
switch(kursus[i].kw)
{
case'a' : case'A' :
strcpy(kursus[i].wk,"Pagi");
kursus[i].biaya2=75000;
break;
case'b' : case'B' :
strcpy(kursus[i].wk,"Sore");
kursus[i].biaya2=100000;
break;
defaut:
cout<<"Kode Salah"<<endl;
getch();
goto y;
break;
}
kursus[i].total=kursus[i].biaya1+kursus[i].biaya2;
}
clrscr();
cout<<"\t\t BUKTI PEMBAYARAN KHURSUS"<<endl;
cout<<"\t\t Global Network "<<endl;
garis();
cout<<"\t Kasir :
"<<nmk<<endl;
cout<<"\t Siswa : "<<siswa<<endl;
cout<<"\t Rincian
Kursus"<<endl;
garis();
cout<<"|No |Materi |Waktu |Biaya1
|Biaya2 |Total |"<<endl;
garis();
for(i=1;i<=n;i++)
{
cout<<setiosflags(ios::left)<<setw(6)<<i;
cout<<setiosflags(ios::left)<<setw(6)<<kursus[i].mt;
cout<<setprecision(10)<<" "<<kursus[i].wk;
cout<<setprecision(10)<<"
"<<"Rp"<<ends<<kursus[i].biaya1;
cout<<setprecision(10)<<"
"<<"Rp"<<ends<<kursus[i].biaya2;
cout<<setprecision(10)<<"
"<<"Rp"<<ends<<kursus[i].total;
cout<<endl;
tobay=tobay+kursus[i].total;
}
garis();
cout<<endl;
cout<<"\t\t\t Total Bayar:
"<<tobay<<endl;
cout<<endl;
cout<<"\t\t\t \2\2\2 Terima Kasih
\2\2\2"<<endl;
getch();
}
Gambar
Hasil Coding C++