yak langsung aja yak, codingan yang pernah gw buat untuk tugas uas gw,,
lumayan banyak,,
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
#include <iomanip.h>
#include <windows.h>
void maaf()
{ clrscr();
cout<<"\n\n\tMOHON MAAF YANG ANDA INPUTKAN SALAH !!!"<<endl;
cout<<"\n\tMOHON TEKAN ";textcolor(10);cprintf("<<ENTER>>");cout<<" UNTUK MENGINPUT KEMBALI !!";
getch();
}
void load()
{ clrscr();
cout<<endl;
cout<<" Please wait";
cout<<endl<<endl<<endl;
cout<<" Loading";
for(int i=0;i<10;i++)
{
cout<<". ";
Sleep(70); //fungsi sleep untuk berhenti sejenak/sebentar
}
}
void loading()
{ clrscr();
cout<<endl;
cout<<"\t\t\t\tPlease wait";
cout<<endl<<endl<<endl;
cout<<"\t\tLoading";
for(int i=0;i<20;i++)
{
cout<<". ";
Sleep(80); //fungsi sleep untuk berhenti sejenak/sebentar
}
}
void judul()
{
cout<<"\t\t\t RESTOURANT"<<endl;
cout<<"\t\t\t \"done\""<<endl;
cout<<"\t\t\t=******************="<<endl;
}
void garis()
{
cout<<"==============================================================================="<<endl;
}
long totalsub(long a,long b)//untuk menghitung totalsub dan subtotal
{ return(a+b); }
long totaldisk(long a,float b)//untuk menghitung diskon
{ return(a*b); }
long tobay_kem(long a,long b)//untuk menghitung total bayar dan uang kembali
{ return(a-b); }
main()
{
int i,x,pilih;
char nama[99],dis[33];
long tobay,ubay,ukem,total,todisk;
float diskon;
struct
{
int pilih_minuman,na_menu,menu_minuman;
long harga1,harga2,subtotal;
char nama_minuman[33],nama_menu[99],pilmenu[22],menu[24],l_min[33],pilihan_menu[33],jenis_menu[33];
}h[33];
awal:
total=0;
clrscr();
judul();
cout<<"\nSELAMAT DATANG DI RESTOURANT \"done\""<<endl;
cout<<"\n\nPILIH :"<<endl;
cout<<"1. INPUT DATA"<<endl;
cout<<"2. LOG OUT"<<endl;
cout<<"========================================="<<endl;
cout<<"MASUKAN YANG ANDA PILIH : ";cin>>pilih;
if(pilih==1)
goto mulai;
else if (pilih==2)
goto akhir;
else
loading();
maaf();
loading();
goto awal;
mulai:
loading();
clrscr();
judul();
cout<<"\n\nMASUKAN NAMA ANDA : ";gets(nama);
strupr(nama); //strupr fungsinya untuk mengKAPITALkan huruf(outputnya akan menjadi huruf kapital)
cout<<"\nBANYAKNYA PILIHAN : ";cin>>x;
for(i=1;i<=x;i++)
{ pertama://label
load();
clrscr();
cout<<"\nMenu Ke-"<<i<<endl;
cout<<"\nPILIH MENU :"<<endl;
cout<<" ^SPESIAL^"<<endl;
cout<<" ^BIASA^"<<endl;
cout<<"INPUT PILIHAN [SP/BS] : ";cin>>h[i].menu;
if((strcmpi(h[i].menu,"SP")==0)||(strcmpi(h[i].menu,"sp")==0))
{ strcpy(h[i].jenis_menu,"SPESIAL");
spesial://label
load(); //spesial1111
clrscr();
cout<<"\nMenu Ke-"<<i<<endl;
cout<<"\nMENU SPESIAL"<<endl;
cout<<" ^KUE^"<<endl;
cout<<" ^MAKANAN^"<<endl;
cout<<" *KEMBALI*"<<endl;
cout<<"INPUT PILIHAN [KU/MK/KB] : ";cin>>h[i].pilmenu;
if((strcmpi(h[i].pilmenu,"KU")==0)||(strcmpi(h[i].pilmenu,"ku")==0))
{ strcpy(h[i].pilihan_menu,"KUE");
aaa://label
load(); //spesila1111kue
clrscr();
cout<<"\nMenu Ke-"<<i<<endl;//menu kue(spesial)
cout<<"\nMENU KUE"<<endl;
cout<<" 1. RAINBOW CAKE Rp.38000"<<endl;
cout<<" 2. CHOCOLATE EMOTION Rp.37000"<<endl;
cout<<" 3. STRAWBERRY CHEESE Rp.36000"<<endl;
cout<<" 4. OREO CHEESE RP.35000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].na_menu;
if(h[i].na_menu==1)
{ strcpy(h[i].nama_menu,"RAINBOW CAKE");
h[i].harga1=38000; }
else if(h[i].na_menu==2)
{ strcpy(h[i].nama_menu,"CHOCOLATE EMOTION");
h[i].harga1=37000; }
else if(h[i].na_menu==3)
{ strcpy(h[i].nama_menu,"STRAWBERRY CHEESE");
h[i].harga1=36000; }
else if(h[i].na_menu==4)
{ strcpy(h[i].nama_menu,"OREO CHEESE");
h[i].harga1=35000; }
else if(h[i].na_menu==8)
goto spesial;
else
{ maaf();
goto aaa; }
}
else if((strcmpi(h[i].pilmenu,"MK")==0)||(strcmpi(h[i].pilmenu,"mk")==0))
{ strcpy(h[i].pilihan_menu,"MAKANAN");
bbb://label //spesial1111makanan
load();
clrscr();
cout<<"\nMenu Ke-"<<i<<endl;//menu makanan(spesial)
cout<<"\nMENU MAKANAN"<<endl;
cout<<" 1. CHICKEN MOZARELA RP.34000"<<endl;
cout<<" 2. KWETIAW SAPI GORENG RP.33000"<<endl;
cout<<" 3. NASI GORENG SEAFOOD RP.32000"<<endl;
cout<<" 4. MIE GORENG SEAFOOD RP.31000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].na_menu;
if(h[i].na_menu==1)
{ strcpy(h[i].nama_menu,"CHICKEN MOZARELA");
h[i].harga1=34000; }
else if(h[i].na_menu==2)
{ strcpy(h[i].nama_menu,"KWETIAW SAPI GORENG");
h[i].harga1=33000; }
else if(h[i].na_menu==3)
{ strcpy(h[i].nama_menu,"NASI GORENG SEAFOOD");
h[i].harga1=32000;}
else if(h[i].na_menu==4)
{ strcpy(h[i].nama_menu,"MIE GORENG SEAFOOD");
h[i].harga1=31000; }
else if(h[i].na_menu==8)
goto spesial;
else
{ maaf();
goto bbb; }
}
else if((strcmpi(h[i].pilmenu,"KB")==0)||(strcmpi(h[i].pilmenu,"kb")==0))
goto pertama; //jika ingin kembali ke sebelumnya
else
{ load(); //jika salah menginputannya(selain ku,mk,kb)
maaf();
goto spesial;
}
minuman://label
load(); //spesial1111minuman
clrscr();
cout<<"\nMenu Ke-"<<i<<endl;//menu minuman(spesial)
cout<<"PILIH MENU MINUMAN"<<endl;
cout<<" 1. DINGIN"<<endl;
cout<<" 2. PANAS"<<endl;
cout<<" 3. JUICE"<<endl;
cout<<" 8. TIDAK PILIH"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].menu_minuman;
if(h[i].menu_minuman==1) //menu minuman dingin(spesial)
{ strcpy(h[i].l_min,"MINUMAN");
cout<<"\nMINUMAN DINGIN"<<endl;
cout<<" 1. ICE GREN TEA RP.17000"<<endl;
cout<<" 2. ICE LEMON TEA RP.18000"<<endl;
cout<<" 3. MILKSHAKE STRAWBERRY RP.19000"<<endl;
cout<<" 4. CAPUCINO RP.18000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].pilih_minuman;
if(h[i].pilih_minuman==1)
{ strcpy(h[i].nama_minuman,"ICE GREN TEA");
h[i].harga2=17000; }
else if(h[i].pilih_minuman==2)
{ strcpy(h[i].nama_minuman,"ICE LEMON TEA");
h[i].harga2=18000; }
else if(h[i].pilih_minuman==3)
{ strcpy(h[i].nama_minuman,"MILIKSHAKE STRAWBERRY");
h[i].harga2=19000; }
else if(h[i].pilih_minuman==4)
{ strcpy(h[i].nama_minuman,"CAPUCINO");
h[i].harga2=18000; }
else if(h[i].pilih_minuman==8)
goto minuman;
else
{ maaf();
goto minuman; }
}
else if(h[i].menu_minuman==2) //menu minuman panas(spesial)
{ strcpy(h[i].l_min,"MINUMAN");
cout<<"\nMINUMAN PANAS"<<endl;
cout<<" 1. KOPI RP.14000"<<endl;
cout<<" 2. TEH RP.12000"<<endl;
cout<<" 3. WEDANG JAHE RP.13000"<<endl;
cout<<" 4. CAPUCINO RP.18000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].pilih_minuman;
if(h[i].pilih_minuman==1)
{ strcpy(h[i].nama_minuman,"KOPI");
h[i].harga2=14000; }
else if(h[i].pilih_minuman==2)
{ strcpy(h[i].nama_minuman,"TEH");
h[i].harga2=12000; }
else if(h[i].pilih_minuman==3)
{ strcpy(h[i].nama_minuman,"WEDANG JAHE");
h[i].harga2=13000; }
else if(h[i].pilih_minuman==4)
{ strcpy(h[i].nama_minuman,"CAPUCINO");
h[i].harga2=18000; }
else if(h[i].pilih_minuman==8)
goto minuman;
else
{ maaf();
goto minuman; }
}
else if(h[i].menu_minuman==3) //menu minuman juice(spesial)
{ strcpy(h[i].l_min,"MINUMAN");
cout<<"\nMINUMAN JUICE"<<endl;
cout<<" 1. ALPUKAT MOCA RP.22000"<<endl;
cout<<" 2. STRAWBERRY RP.19000"<<endl;
cout<<" 3. CHOCOLATE RP.20000"<<endl;
cout<<" 4. ORANGE RP.19000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].pilih_minuman;
if(h[i].pilih_minuman==1)
{ strcpy(h[i].nama_minuman,"JUICE ALPUKAT MOCA");
h[i].harga2=22000; }
else if(h[i].pilih_minuman==2)
{ strcpy(h[i].nama_minuman,"JUICE STRAWBERRY");
h[i].harga2=19000; }
else if(h[i].pilih_minuman==3)
{ strcpy(h[i].nama_minuman,"JUICE CHOCOLATE");
h[i].harga2=20000; }
else if(h[i].pilih_minuman==4)
{ strcpy(h[i].nama_minuman,"JUICE ORANGE");
h[i].harga2=19000; }
else if(h[i].pilih_minuman==8)
goto minuman;
else
{ maaf();
goto minuman; }
}
else if(h[i].menu_minuman==8) //jika tidak memilih minuman(spesial)
{ strcpy(h[i].l_min,"MINUMAN");
strcpy(h[i].nama_minuman,".....");
h[i].harga2=0;
}
else //jika salah menginputkan minuman(spesial)
{
load();
maaf();
goto minuman;
}
}
else if((strcmpi(h[i].menu,"bs")==0)||(strcmpi(h[i].menu,"BS")==0))
{ strcpy(h[i].jenis_menu,"BIASA");
biasa://label //biasa2222
load();
clrscr();
cout<<"\nMenu Ke-"<<i<<endl;
cout<<"\nPILIH"<<endl;
cout<<" ^KUE^"<<endl;
cout<<" ^MAKANAN^"<<endl;
cout<<" *KEMBALI*"<<endl;
cout<<"INPUT PILIHAN [KU/MK/KB] : ";cin>>h[i].pilmenu;
if((strcmp(h[i].pilmenu,"KU")==0)||(strcmp(h[i].pilmenu,"ku")==0))
{ strcpy(h[i].pilihan_menu,"KUE");
ccc://label //biasa2222kue
load();
clrscr();
cout<<"\nMenu Ke-"<<i<<endl;//menu kue(biasa)
cout<<"\nMENU KUE"<<endl;
cout<<" 1. CHOCOLATE KARAMEL RP.34000"<<endl;
cout<<" 2. VANILA FRUITS RP.33000"<<endl;
cout<<" 3. STRAWBERRY CURD RP.32000"<<endl;
cout<<" 4. BLACK FOREST RP.31000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].na_menu;
if (h[i].na_menu==1)
{ strcpy(h[i].nama_menu,"CHOCOLATE KARAMEL");
h[i].harga1=34000; }
else if(h[i].na_menu==2)
{ strcpy(h[i].nama_menu,"VANILA FRUITS");
h[i].harga1=33000; }
else if(h[i].na_menu==3)
{ strcpy(h[i].nama_menu,"STRAWBERRY CURD");
h[i].harga1=32000; }
else if(h[i].na_menu==4)
{ strcpy(h[i].nama_menu,"BLACK FOREST");
h[i].harga1=31000; }
else if(h[i].na_menu==8)
goto biasa;
else
{ maaf();
goto ccc; }
}
else if((strcmpi(h[i].pilmenu,"MK")==0)||(strcmpi(h[i].pilmenu,"mk")==0))
{ strcpy(h[i].pilihan_menu,"MAKANAN");
ddd://label //biasa2222makanan
load();
clrscr();
cout<<"\nMenu Ke-"<<i<<endl;//menu makanan(biasa)
cout<<"\nPILIH MENU MAKANAN"<<endl;
cout<<" 1. CHICKEN CRISPY RP.31000"<<endl;
cout<<" 2. MIE AYAM RP.26000"<<endl;
cout<<" 3. NASI GORENG SOSIS RP.27000"<<endl;
cout<<" 4. KWETIAW AYAM BAKSO RP.29000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].na_menu;
if(h[i].na_menu==1)
{ strcpy(h[i].nama_menu,"CHICKEN CRISPY");
h[i].harga1=31000; }
else if(h[i].na_menu==2)
{ strcpy(h[i].nama_menu,"MIE AYAM");
h[i].harga1=26000; }
else if(h[i].na_menu==3)
{ strcpy(h[i].nama_menu,"NASI GORENG SOSIS");
h[i].harga1=27000; }
else if(h[i].na_menu==4)
{ strcpy(h[i].nama_menu,"KWETIAW AYAM BAKSO");
h[i].harga1=29000; }
else if(h[i].na_menu==8)
goto biasa;
else
{ maaf();
goto ddd; }
}
else if((strcmpi(h[i].pilmenu,"KB")==0)||(strcmpi(h[i].pilmenu,"kb")==0))
goto pertama; //jika ingin kembali ke sebelumnya
else
{ load(); //jika kesalahan dalam penginputannya(selain ku,mk,kb)
maaf();
goto biasa;
}
minuman1://label
load(); //biasa2222minuman
clrscr();
cout<<"\nMenu Ke-"<<i<<endl;//menu minuman(biasa)
cout<<"PILIH MENU MINUMAN"<<endl;
cout<<" 1. DINGIN"<<endl;
cout<<" 2. PANAS"<<endl;
cout<<" 3. JUICE"<<endl;
cout<<" 8. TIDAK PILIH"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].menu_minuman;
if(h[i].menu_minuman==1)
{ strcpy(h[i].l_min,"MINUMAN"); //menu minuman dingin(biasa)
cout<<"\nMINUMAN DINGIN"<<endl;
cout<<" 1. ICE TEA RP.13000"<<endl;
cout<<" 2. ES KELAPA MUDA RP.17000"<<endl;
cout<<" 3. COCO COLA RP.15000"<<endl;
cout<<" 4. CAPUCINO RP.18000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].pilih_minuman;
if(h[i].pilih_minuman==1)
{ strcpy(h[i].nama_minuman,"ICE TEA");
h[i].harga2=13000; }
else if(h[i].pilih_minuman==2)
{ strcpy(h[i].nama_minuman,"ES KELAPA MUDA");
h[i].harga2=17000; }
else if(h[i].pilih_minuman==3)
{ strcpy(h[i].nama_minuman,"COCO COLA");
h[i].harga2=15000; }
else if(h[i].pilih_minuman==4)
{ strcpy(h[i].nama_minuman,"CAPUCINO");
h[i].harga2=18000; }
else if(h[i].pilih_minuman==8)
goto minuman1;
else
{ maaf();
goto minuman1; }
}
else if(h[i].menu_minuman==2) //menu minuman panas(biasa)
{ strcpy(h[i].l_min,"MINUMAN");
cout<<"\nMINUMAN PANAS"<<endl;
cout<<" 1. KOPI RP.14000"<<endl;
cout<<" 2. TEH RP.12000"<<endl;
cout<<" 3. WEDANG JAHE RP.13000"<<endl;
cout<<" 4. CAPUCINO RP.18000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].pilih_minuman;
if(h[i].pilih_minuman==1)
{ strcpy(h[i].nama_minuman,"KOPI");
h[i].harga2=14000; }
else if(h[i].pilih_minuman==2)
{ strcpy(h[i].nama_minuman,"TEH");
h[i].harga2=12000; }
else if(h[i].pilih_minuman==3)
{ strcpy(h[i].nama_minuman,"WEDANG JAHE");
h[i].harga2=13000; }
else if(h[i].pilih_minuman==4)
{ strcpy(h[i].nama_minuman,"CAPUCINO");
h[i].harga2=18000; }
else if(h[i].pilih_minuman==8)
goto minuman1;
else
{ maaf();
goto minuman1; }
}
else if(h[i].menu_minuman==3) //menu minuman juise(biasa)
{ strcpy(h[i].l_min,"MINUMAN");
cout<<"\nMINUMAN JUICE"<<endl;
cout<<" 1. ALPIKAT RP.20000"<<endl;
cout<<" 2. STRAWBERRY RP.19000"<<endl;
cout<<" 3. CHOCOLATE RP.20000"<<endl;
cout<<" 4. ORANGE RP.19000"<<endl;
cout<<" 8. KEMBALI"<<endl;
cout<<"INPUT PILIHAN : ";cin>>h[i].pilih_minuman;
if(h[i].pilih_minuman==1)
{ strcpy(h[i].nama_minuman,"JUICE ALPUKAT");
h[i].harga2=22000; }
else if(h[i].pilih_minuman==2)
{ strcpy(h[i].nama_minuman,"JUICE STRAWBERRY");
h[i].harga2=19000; }
else if(h[i].pilih_minuman==3)
{ strcpy(h[i].nama_minuman,"JUICE CHOCOLATE");
h[i].harga2=20000; }
else if(h[i].pilih_minuman==4)
{ strcpy(h[i].nama_minuman,"JUICE ORANGE");
h[i].harga2=19000; }
else if(h[i].pilih_minuman==8)
goto minuman1;
else
{ maaf();
goto minuman1; }
}
else if(h[i].menu_minuman==8) //jika tidak memilih minuman(biasa)
{ strcpy(h[i].l_min,"MINUMAN");
strcpy(h[i].nama_minuman,".....");
h[i].harga2=0;
}
else
{ load(); //jika salam menginputkan minuman(biasa) selain 1,2,3,8
maaf();
goto minuman1;
}
}
else
{ loading(); //jika inputan selain spesial(SP) ATAU biasa(BS)
maaf();
goto pertama;
}
}
loading();
auah://label
clrscr();
judul();
cout<<"\n\n\nNAMA PEMBELI : "<<nama<<endl<<endl;
garis();
cout<<" NO MENU PILIHAN NAMA MENU HARGA SUBTOTAL"<<endl;
garis();
for(i=1;i<=x;i++)
{ cout<<" ";
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(11)<<h[i].jenis_menu; //outputnya
cout<<setiosflags(ios::left)<<setw(12)<<h[i].pilihan_menu;
cout<<setiosflags(ios::left)<<setw(26)<<h[i].nama_menu;
cout<<setiosflags(ios::left)<<"Rp."<<setw(1)<<h[i].harga1<<endl;
cout<<" ";
cout<<setiosflags(ios::left)<<setw(12)<<h[i].l_min;
cout<<setiosflags(ios::left)<<setw(26)<<h[i].nama_minuman;
cout<<setiosflags(ios::left)<<"Rp."<<setw(1)<<h[i].harga2<<endl;
h[i].subtotal=totalsub(h[i].harga1,h[i].harga2);
cout<<" ";
cout<<setiosflags(ios::left)<<"Rp."<<setw(1)<<h[i].subtotal<<endl;
total=totalsub(total,h[i].subtotal);
}
garis();
cout<<"\t\t\t\t\t\t Total : Rp."<<total<<endl;
if(total<100000)
{ strcpy(dis,"0%");
diskon=0;
}
else if(total>=100000&&total<150000)
{ strcpy(dis,"5%");
diskon=0.05; //ketentuan diskonnya
}
else if(total>=150000&&total<250000)
{ strcpy(dis,"7%");
diskon=0.07;
}
else if(total>=250000)
{ strcpy(dis,"10%");
diskon=0.10;
}
todisk=totaldisk(total,diskon); //rumus menghitung diskon
cout<<"\t\t\t\t\t\t Diskon : Rp."<<todisk<<" ("<<dis<<")"<<endl;
tobay=tobay_kem(total,todisk); //rumus menghitungg total bayar
cout<<"\t\t\t\t\t\t Total bayar : Rp."<<tobay<<endl;
cout<<"\t\t\t\t\t\t Uang Bayar : Rp.";cin>>ubay;
if(ubay<tobay)
{ loading(); //ketentuan jika uang bayar kurang dari total bayar
clrscr();
textcolor(14);cprintf("\n WARNING !!\n");
cout<<"\n\n\tMOHON MAAF UANG BAYAR ANDA, LEBIH KECIL DARI TOTAL BAYAR !!!"<<endl;
cout<<"\n\tMOHON TEKAN ";textcolor(10);cprintf("<<ENTER>>");cout<<" UNTUK MENGINPUT KEMBALI UANG BAYAR ANDA...";
total=total-total; //rumus,agar total tidak bertambah
getch();
loading();
goto auah;
}
else if(ubay>=tobay)
{ ukem=tobay_kem(ubay,tobay); }
cout<<"\t\t\t\t\t\t Uang Kembali : Rp."<<ukem<<endl<<endl<<endl;
cout<<" TERIMA KASIH !! MAKANAN & MINUMAN AKAN SEGERA DIANTARKAN :) "<<endl;
getch();
loading();
goto awal;
akhir://label
loading();
}
sekian, semoga bisa di run ya...
Tidak ada komentar:
Posting Komentar