Script :
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
/*FUNGSI UNTUK
MENAMPILKAN HEADER */
header()
{
printf("\t===================================================================\n");
printf("\t||\t\t SANTIAGO BARNABEAU CAFFE
AND RESTO\t\t ||\n");
printf("\t||\t\t Real St. No.133 Madrid
Espana \t\t\t ||\n");
printf("\t===================================================================\n");
}
main(){
char
user[20],pwd[20],kode[5][20],menu[20][30],lagi[1];
int coba=0, i=0, jmlitem=0,jmlbeli[20];
double
subtotal[20],total=0,harga[20],bayar,kembali;
awal:
clrscr();
/* FUNGSI FERIFIKASI LOGIN */
login:
header();
printf("\n\n\n\n");
cout<<"\t\t USER ID \t :
";cin>>user;
strupr(user);
cout<<"\t\t PASSWORD \t :
";cin>>pwd;
strupr(pwd);
if(!strcmp(user,"RONALDO")
&& !strcmp(pwd,"BENZEMA")){
goto program;
}else {
if(coba==3){
clrscr();
printf("Percobaan
Login Gagal\n Silahkan Ulangi Beberapa Saat Lagi !!");
goto
ahir;
}
coba=coba++;
clrscr();
printf("Maaf USER atau Password anda
salah.. :( \n Mencoba Login Ke-%i\n",coba);
goto login;
}
/*PROGRAM UTAMA */
program:
clrscr();
header();
cout<<"\t\t\t
Jumlah Item Menu yang Dipesan\t: ";cin>>jmlitem;
/*INPUT KODE MENU */
for(i=1;i<=jmlitem;i++){
cout<<"\t---------------------------------\n";
cout<<"\tItem
Ke-"<<i<<endl;
cout<<"\tKode Menu\t:
";cin>>kode[i];
strupr(kode[i]);
cout<<"\tJumlah Beli\t:
";cin>>jmlbeli[i];
/*PROSES */
if(!strcmp(kode[i],"MN001")){
strcpy(menu[i],"NASI BAKAR");
harga[i]=15000;
subtotal[i]=harga[i]*jmlbeli[i];
}else
if(!strcmp(kode[i],"MN002")){
strcpy(menu[i],"NASI GORENG");
harga[i]=10000;
subtotal[i]=harga[i]*jmlbeli[i];
}else
if(!strcmp(kode[i],"MN003")){
strcpy(menu[i],"NASI GOSONG");
harga[i]=20000;
subtotal[i]=harga[i]*jmlbeli[i];
}else if(!strcmp(kode[i],"MN004")){
strcpy(menu[i],"NASI LIWET");
harga[i]=25000;
subtotal[i]=harga[i]*jmlbeli[i];
}else {
clrscr();
header();
printf("Maaf Kode Item Tidak Ditemukan\n");
i=i-1;
}
/*PROSES MENGHITUNG
TOTAL */
total=total+subtotal[i];
}
/*HASIL OUTPUT */
clrscr();
header();
printf("\n\t------------------------------------------------------------------\n");
printf("\tItem
Ke | Nama Item | Harga Rp.
| Jumlah Beli | Subtotal Rp. |");
printf("\n\t------------------------------------------------------------------\n");
for(i=1;i<=jmlitem;i++){
cout<<"\t"<<setiosflags(ios::left)<<setw(10)<<i;
cout<<setprecision(2)<<"
"<<menu[i];
cout<<setprecision(10)<<"\t
"<<harga[i];
cout<<setprecision(10)<<"\t\t
"<<jmlbeli[i];
cout<<setprecision(10)<<"\t\t
"<<subtotal[i]<<endl;
}
printf("\t------------------------------------------------------------------\n");
cout<<"\tTotal
Bayar \t\t : Rp."<<total<<endl;
printf("\t------------------------------------------------------------------\n");
/*MENGHITUNG UANG
KEMBALI */
bayar:
cout<<"\t\t\t\t
Uang Bayar Rp. : ";cin>>bayar;
if(bayar<total){
cout<<"\n\t\t\t\t
Uang Bayar Kurang... :( ";
goto bayar;
}else {
kembali=bayar-total;
}
cout<<"\t\t\t\t
Uang Kembali Rp. : "<<kembali<<endl;
/* INPUT ULANG */
cout<<"\t\t
Input Data Lagi..??[Y/T]";cin>>lagi;
if(!strcmp(lagi,"Y")||!strcmp(lagi,"y")){
goto awal;
}
ahir:
getch();
}
Selamat Mencoba Yosh !!!
Selamat Mencoba Yosh !!!
Tidak ada komentar:
Posting Komentar