#include<iostream>
#include<windows.h>
#include <conio.h>
#include <string> //memakai 4 heder
using namespace std;
struct kopi{//menyajikan data yg mau di masukan ke perogram/array of
int harga_barang,jumlah_barang;
string nama_barang,nama_pelanggan;
}pesanan[100];
int in,n,k,temp,total_belanja; //tipe data
string temp1,cari1,username,password;
float diskon,bayar,temp2;
char lagi;
//Procedure 9
void timer_3s(){//untuk waktu/ time yg udah di tentukan
Sleep (3000);//milidetik
}
void login(string&u,string&p) {//by refr
balik_user:
system ("cls");
cout <<"+===================================================+"<<endl;
cout <<"| \tLogin |" << endl;
cout <<"+===================================================+" << endl;
cout<<"Username : "; cin>>u;
cout<<"Password : "; cin>>p;
if (u == "owner" && p == "1"){
system("cls");
cout<<"Login Berhasil"<<endl<<endl;
}
else{
cout<<"Username atau Password yang dimasukkan Salah !!"<<endl;
cout<<"\n\nAnda Akan Dialihkan Ke Menu Utama...\n";
timer_3s();
cout<<"\nTekan Apa saja untuk kembali ke menu..."; getch();
system("cls");
goto balik_user;
}
}
void menu(){
cout<<" +=======================================+"<<endl;
cout<<" | MENU La Du CAFE |"<<endl;
cout<<" +=======================================+"<<endl;
cout<<" | NAMA | HARGA |"<<endl;
cout<<" +=======================================+"<<endl;
cout<<" | Kopi Hitam |\t: Rp. 7000 |"<<endl;
cout<<" | Latte |\t: Rp. 6000 |"<<endl;
cout<<" | Cappucino |\t: Rp. 5500 |"<<endl;
cout<<" | Capcin |\t: Rp. 8500 |"<<endl;
cout<<" | Milo |\t: Rp. 4000 |"<<endl;
cout<<" +=======================================+"<<endl;
cout<<endl;
}
void menu1(){
system("cls");
cout<<"APLIKASI PENGURUTAN DAN PENCARI PESANAN"<<endl;
cout<<"1.LIHAT HASIL PESANAN"<<endl;
cout<<"2.ASCENDING "<<endl;
cout<<"3.DESCENDING"<<endl;
cout<<"4.CETAK STRUK"<<endl;
cout<<"5.PENCARIAN NAMA PELANGGAN"<<endl;
cout<<"6.PESANAN BARU / EXIT "<<endl;
cout<<endl;
}
void lihat(){
system("cls");
cout<<" ___________________________________________________"<<endl;
cout<<"|| LIHAT PESANAN ||"<<endl;
cout<<"+___________________________________________________+"<<endl;
cout<<endl;
for (in=1;in<=n;in++){
cout<<endl;
cout<<"|| Nama Pelanggan : "<<pesanan[in].nama_pelanggan;
cout<<endl;
cout<<"\n Nama Pesanan : "<<pesanan[in].nama_barang;
cout<<"\n Harga : "<<pesanan[in].harga_barang;
cout<<"\n Jumlah Beli : "<<pesanan[in].jumlah_barang;
cout<<endl;
total_belanja=pesanan[in].harga_barang*pesanan[in].jumlah_barang;
cout<<" TOTAL BELANJA : Rp. "<<total_belanja<<endl;
cout<<"________________________________________________________"<<endl;
}
system("pause");
}
void bblasc(){
system("cls");
cout<<"+============================+"<<endl;
cout<<"| proses sorting Asc |"<<endl;
cout<<"+============================+"<<endl;
cout<<endl;
for(in=1;in<=n;in++){
for(k=n;k>=in+1;k--){
if(pesanan[k].nama_barang<pesanan[k-1].nama_barang){
temp1=pesanan[k].nama_barang;
pesanan[k].nama_barang=pesanan[k-1].nama_barang;
pesanan[k-1].nama_barang=temp1;
temp=pesanan[k].harga_barang;
pesanan[k].harga_barang=pesanan[k-1].harga_barang;
pesanan[k-1].harga_barang=temp;
temp=pesanan[k].jumlah_barang;
pesanan[k].jumlah_barang=pesanan[k-1].jumlah_barang;
pesanan[k-1].jumlah_barang=temp;
temp1=pesanan[k].nama_pelanggan;
pesanan[k].nama_pelanggan=pesanan[k-1].nama_pelanggan;
pesanan[k-1].nama_pelanggan=temp1;
}
}
}
cout<<endl;
for(in=1;in<=n;in++){
cout<<endl;
cout<<"|| Nama Pelanggan : "<<pesanan[in].nama_pelanggan;
cout<<endl;
cout<<"\n Nama pesanan : "<<pesanan[in].nama_barang;
cout<<"\n Harga : "<<pesanan[in].harga_barang;
cout<<"\n Jumlah Beli : "<<pesanan[in].jumlah_barang;
total_belanja=pesanan[in].harga_barang*pesanan[in].jumlah_barang;
cout<<endl;
if(total_belanja >= 10000){
cout<<"\nDapat diskon 5%"<<endl;
diskon=total_belanja*0.05;
bayar=total_belanja-diskon;
cout<<"Anda bayar : Rp. "<<bayar;
cout<<endl;
}
else{
cout<<"\nTidak ada diskon"<<endl;
cout<<"\nAnda bayar : Rp. "<<total_belanja;
cout<<endl;
}
cout<<"____________________________________________________________"<<endl;
}
system("pause");
cout<<endl;
}
void bbldesc(){
system("cls");
cout<<"+============================+"<<endl;
cout<<"| proses sorting Desc |"<<endl;
cout<<"+============================+"<<endl;
for(in=1;in<=n;in++){
for(k=n;k>=in+1;k--){
if(pesanan[k].nama_barang>pesanan[k-1].nama_barang){
temp1=pesanan[k].nama_barang;
pesanan[k].nama_barang=pesanan[k-1].nama_barang;
pesanan[k-1].nama_barang=temp1;
temp=pesanan[k].harga_barang;
pesanan[k].harga_barang=pesanan[k-1].harga_barang;
pesanan[k-1].harga_barang=temp;
temp=pesanan[k].jumlah_barang;
pesanan[k].jumlah_barang=pesanan[k-1].jumlah_barang;
pesanan[k-1].jumlah_barang=temp;
temp1=pesanan[k].nama_pelanggan;
pesanan[k].nama_pelanggan=pesanan[k-1].nama_pelanggan;
pesanan[k-1].nama_pelanggan=temp1;
}
}
}
cout<<endl;
for(in=1;in<=n;in++){
cout<<endl;
cout<<endl;
cout<<"|| Nama Pelanggan : "<<pesanan[in].nama_pelanggan;
cout<<endl;
cout<<"\n Nama Pesanan : "<<pesanan[in].nama_barang;
cout<<"\n Harga : "<<pesanan[in].harga_barang;
cout<<"\n Jumlah Beli : "<<pesanan[in].jumlah_barang;
//rumus perhitungan
total_belanja=pesanan[in].harga_barang*pesanan[in].jumlah_barang;
cout<<endl;
if(total_belanja >= 10000){
cout<<"\nDapat diskon 5%"<<endl;
diskon=total_belanja*0.05;
bayar=total_belanja-diskon;
cout<<"\nAnda bayar : Rp. "<<bayar;
cout<<endl;
}
else{
cout<<"\nTidak ada diskon"<<endl;
cout<<"Anda bayar : Rp. "<<total_belanja;
cout<<endl;
}
cout<<"____________________________________________________________"<<endl;
}
system("pause");
cout<<endl;
}
void sequen(string& x){
system("cls");
int ketemu;
cout<<"+==========================================+"<<endl;
cout<<"| proses sequential search | "<<endl;
cout<<"+==========================================+"<<endl<<endl;
cout<<"Berdasarkan Nama Pemesan : ";cin>>x;
cout<<endl;
ketemu=0;
cout<<endl;
for(in=1;in<=n;in++){
if(cari1== pesanan[in].nama_pelanggan){
cout<<endl;
cout<<"Data ditemukan di-"<<in<<endl;
ketemu=1;
cout<<endl;
cout<<"|| Nama Pelanggan : "<<pesanan[in].nama_pelanggan;
cout<<endl;
cout<<"\n Nama Pesanan : "<<pesanan[in].nama_barang;
cout<<"\n Harga : "<<pesanan[in].harga_barang;
cout<<"\n Jumlah Beli : "<<pesanan[in].jumlah_barang;
cout<<endl;
total_belanja=pesanan[in].harga_barang*pesanan[in].jumlah_barang;
cout<<" TOTAL BELANJA : Rp."<<total_belanja<<endl;
cout<<"______________________________________________________"<<endl;
}
}
cout<<endl;
if(ketemu==1){
cout<<"Data ada !"<<endl;
}
else{
cout<<"Data tidak ada !"<<endl;
}
system("pause");
}
void cetak_struk(){
system("cls");
cout<<"+===================================================+"<<endl;
cout<<"| CETAK STRUK |"<<endl;
cout<<"+===================================================+"<<endl;
cout<<endl;
for(in=1;in<=n;in++){
cout<<"|| Nama Pelanggan : "<<pesanan[in].nama_pelanggan<<endl;
cout<<endl;
cout<<"|| Nama Pesanan : "<<pesanan[in].nama_barang<<endl;
cout<<"|| Harga : "<<pesanan[in].harga_barang<<endl;
cout<<"|| Jumlah Beli : "<<pesanan[in].jumlah_barang<<endl;
cout<<endl;
total_belanja=pesanan[in].harga_barang*pesanan[in].jumlah_barang;
cout<<" Total Belanja : Rp. "<<total_belanja<<endl;
cout<<endl;
if(total_belanja >= 10000){
cout<<"\nDapat diskon 5%"<<endl;
diskon=total_belanja*0.05;
bayar=total_belanja-diskon;
cout<<"Total Setelah Diskon : Rp. "<<bayar<<endl;
cout<<endl;
}
else{
cout<<"\nTidak ada diskon"<<endl;
cout<<" Total : Rp. "<<total_belanja<<endl;
cout<<endl;
}
cout<<"____________________________________________________________"<<endl;
}
system("pause");
}
int main(){
system("color A");
login(username,password);
cout<<" Loading....";
timer_3s();
system("cls");
lagilagi:
menu();
cout<<endl;
cout<<"+===============================+"<<endl;
cout<<"| INPUT PESANAN | "<<endl;
cout<<"+===============================+"<<endl;
cout<<endl;
cout<<"Jumlah Pesanan : ";cin>>n;
cout<<endl;
for(in=1;in<=n;in++){
cout<<"Nama Pelanggan ke-"<<in<<" : ";cin>>pesanan[in].nama_pelanggan;
lagi:
cout<<"Nama Barang : ";cin>>pesanan[in].nama_barang;
cout<<"Harga Barang : ";cin>>pesanan[in].harga_barang;
cout<<"Jumlah Beli : ";cin>>pesanan[in].jumlah_barang;
cout<<endl;
cout<<endl;
}
mau:
system("cls");
menu1();
int p;
char close;
cout<<"Pilih : ";cin>>p;
switch(p){
case 1 :{
lihat();goto mau;
break;
case 2 :{
bblasc();goto mau;
break;
}
case 3 :{
bbldesc();goto mau;
break;
}
case 4:{
cetak_struk();goto mau;
break;
}
case 5:{
sequen(cari1);goto mau;
break;
}
case 6:{
cout<<"\nAPAKAH ANDA PESAN LAGI ? Y/N : ";cin>>close;
if(close == 'Y' ){
system("cls");
goto lagilagi;
}
else if(close == 'N'){
cout<<endl;
cout<<" TERIMA KASIH "<<endl;
exit;
}
break;
}
}
}
}
0 comments