kagemaro

Project Uas Final

Jan 12th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <iostream.h>
  4. #include <iomanip.h>
  5. #include <string.h>
  6. #include <windows.h>
  7. long potong (int p){
  8.    float diskon;
  9.     if(p >= 100000)
  10.    {
  11.    diskon = p * 0.10;}
  12.    else
  13.    {
  14.    p = 0;
  15.    diskon = 0;}
  16.    return(p - diskon);
  17. }
  18.  
  19. title()
  20. {
  21.     cout<<"              Grillicious"<<endl;
  22.     cout<<"         Yummy Grills and More"<<endl;
  23.     cout<<"      ==========================="<<endl;
  24.     }
  25. garis()
  26. {
  27. cout<<"============================================";
  28. }
  29. menu(){
  30.     cout<<"\n*************************************************"<<endl;
  31.     cout<<"**               Today's Menu                  **"<<endl;
  32.     cout<<"*************************************************"<<endl;
  33.     cout<<"**  Meal                                      **"<<endl;
  34.     cout<<"** 1.Sosis Ayam Bakar         : Rp.10000 -,   **"<<endl;
  35.     cout<<"** 2.Sosis Sapi Bakar         : Rp.12000 -,   **"<<endl;
  36.     cout<<"** 3.Sosis Black Papper Bakar : Rp.11000 -,   **"<<endl;
  37.     cout<<"** 4.Sosis Cheese Bakar       : Rp.13000 -,   **"<<endl;
  38.     cout<<"** 5.Bakso Bakar              : Rp.8000 -,    **"<<endl;
  39.     cout<<"**                                            **"<<endl;
  40.     cout<<"** Beverages                                  **"<<endl;
  41.     cout<<"** 6.Coke                     : Rp.5000-,     **"<<endl;
  42.     cout<<"** 7.Ice Tea                  : Rp.5000-,     **"<<endl;
  43.     cout<<"** 8.Water                    : Rp.3000-,     **"<<endl;
  44.     cout<<"**                                            **"<<endl;
  45.     cout<<"************************************************"<<endl;
  46.     }
  47.  
  48.  void delay(int a)//Loading Screen
  49.     {
  50.         for(int x=0;x<a*50;x++)
  51. {
  52.         for(int y=0;y<a*50;y++)
  53.             {}
  54.     }
  55. }
  56. void readPass(char*);
  57. main() //Ini main jangan ngilang lagi
  58. {
  59.     gotoxy(32,11);cout<<"============";
  60.     gotoxy(32,13);cout<<"============";
  61.     for(int i=0;i<=100;i++){
  62.     delay(80);
  63.     gotoxy(32,12);cout<<"loading "<<i<<"%";
  64.     }
  65.  
  66. char user[40];
  67. char pass[30],username[30][30]={"doni","bagus","eko","pandu"};
  68. char lagi;
  69.  
  70. int input;
  71.  
  72. //Tampilan Awal
  73. clrscr();
  74. title();
  75.     cout<<"Welcome to Grillicious Yummy Grills and More"<<endl;
  76.     cout<<"Choose your menu to work: "<<endl;
  77. garis();
  78.     cout<<"\n 1.Input Menu"<<endl;
  79.     cout<<" 2.Logout"<<endl;
  80. garis();
  81.     cout<<"\n Input here: ";
  82.     cin>>input;endl;
  83.  
  84.     clrscr();
  85.  
  86. title();
  87. if(input==1){
  88. garis();
  89.  
  90.     cout<<"\n User name: ";
  91.     cin>>user;
  92.     cout<<endl;
  93.     cout<<" Password: ";
  94.     cin>>pass;
  95.  
  96.  
  97. if(strcmp(username[0],user) == 0
  98.     || strcmp(username[1],user) == 0
  99.    || strcmp(username[2],user) == 0
  100.    || strcmp(username[3],user) == 0
  101.    && strcmp ("grillicious",pass) == 0){
  102.  
  103.   void loading();
  104.          cout << "\n======================================= \n\n";Sleep(600);
  105.          cout << "|         Anda Berhasil Login         |"<<endl;Sleep(1000);
  106.          cout << "======================================= \n\n";Sleep(600);
  107.          cout<<endl;
  108.    goto menu;
  109.    }
  110. if(pass!="grillicious")
  111.          { cout << "==========================================\n\n";Sleep(600);
  112.          cout << "|     PASSWORD/USERNAME ANDA SALAH!!!!   |\n"<<endl;Sleep(1000);
  113.          cout << "==========================================\n\n";Sleep(600);
  114.          cout<<endl;
  115.    return 0;
  116.    }}
  117.  
  118. //Tampilan input
  119. do{menu:
  120. clrscr();
  121. title();
  122. cout<<"\n** Logged Username: "<<user<<" **"<<endl;
  123. cout<<"** Today's Promo:         **"<<endl;
  124. cout<<"** -Discount 5%,Setiap transaksi Rp.100.000-, atau lebih- **"<<endl;
  125. menu();
  126.  
  127.  
  128.     int i,jp;
  129.     struct{
  130.     int banyak;
  131.     char item[30];
  132.     long harga,jumlah ;
  133.     }array[100];
  134.  
  135.     struct{
  136.     char nama[20];
  137.     int m;
  138.     }data;
  139.  
  140.         cout<<"Nama Pelangggan: ";
  141.         gets(data.nama);
  142.         cout<<"Input Jumlah Pesanan: ";
  143.         cin>>jp;
  144.         for(i=1;i<=jp;i++){
  145.         cout<<endl;
  146.         cout<<"Data ke-"<<i<<endl;
  147.         cout<<"Input Menu: ";
  148.         cin>>data.m;
  149.         if(data.m==1){
  150.         strcpy(array[i].item,"Sosis ayam bakar");
  151.         array[i].harga=10000;
  152.         }
  153.         if(data.m==2){
  154.         strcpy(array[i].item,"Sosis sapi bakar");
  155.         array[i].harga=12000;
  156.         }
  157.         if(data.m==3){
  158.         strcpy(array[i].item,"Sosis Black pepper bakar");
  159.         array[i].harga=11000;
  160.         }
  161.         if(data.m==4){
  162.         strcpy(array[i].item,"Sosis Cheese Bakar");
  163.         array[i].harga=13000;
  164.         }
  165.         if(data.m==5){
  166.         strcpy(array[i].item,"Bakso Bakar");
  167.         array[i].harga=8000;
  168.         }
  169.         if(data.m==6){
  170.         strcpy(array[i].item,"Coke");
  171.         array[i].harga=5000;
  172.         }
  173.         if(data.m==7){
  174.         strcpy(array[i].item,"Ice Tea");
  175.         array[i].harga=5000;
  176.         }
  177.         if(data.m==8){
  178.         strcpy(array[i].item,"Water");
  179.         array[i].harga=3000;
  180.         }
  181.  
  182.  
  183.     cout<<endl;
  184.     cout<<"Anda memesan: "<<array[i].item<<endl;
  185.     cout<<"Dengan harga: Rp."<<array[i].harga<<endl;
  186.     cout<<"Input Banyaknya: ";
  187.     cin>>array[i].banyak;
  188.     array[i].jumlah=array[i].harga*array[i].banyak;
  189.     cout<<"Jumlah: "<<array[i].jumlah;
  190.     cout<<endl;}
  191.  
  192.  
  193. //Tampilan Output
  194.  
  195.  
  196. struct{
  197. long total,dibayar,kembali,kurang,disc;
  198. }data2;
  199.  
  200. data2.total=0;
  201. for (i=1;i<=jp;i++)
  202. {
  203. data2.total+=array[i].jumlah;
  204. }
  205. clrscr();
  206. title();
  207.  
  208.      cout<<"Nama Pelanggan :"<<data.nama<<endl;
  209.     cout<<"Daftar menu yang dipesan"<<endl;
  210.     cout<<"======================================================"<<endl;
  211.     cout<<"No     Item             Price     Qty      Total      "<<endl;
  212.     cout<<"======================================================"<<endl;
  213.     for(i=1;i<=jp;i++){
  214.         cout<<setiosflags(ios::left)<<setw(5)<<i;
  215.       cout<<setiosflags(ios::left)<<setw(24)<<array[i].item;
  216.       cout<<setprecision(30)<<setw(10)<<array[i].harga;
  217.       cout<<setprecision(20)<<setw(10)<<array[i].banyak;
  218.       cout<<setprecision(20)<<setw(10)<<array[i].jumlah<<endl;
  219.         }
  220.  
  221.  
  222.  
  223. cout<<"Total belanja: "<<data2.total<<endl;
  224. cout<<"Masukkan uang yang dibayar: ";
  225. cin>>data2.dibayar;endl;
  226.  
  227. if(potong(data2.total <= 0)){
  228. data2.disc = 0;}
  229. else
  230. {
  231. data2.disc = potong(data2.total);
  232. }
  233. if(data2.disc <= 0){
  234. cout<<"\n Anda tidak mendapatkan Discount "<<endl;
  235. cout<<"\n Diskon 5% jika belanja minimal Rp.100.000-,";
  236. }
  237. else{
  238. cout<<"\nAnda mendapatkan diskon sebesar: "<<data2.disc;
  239. }
  240. if(data2.disc <= 0){
  241. data2.kembali=data2.dibayar-data2.total;}
  242. else{
  243. data2.kembali=data2.dibayar-data2.disc;
  244. }
  245. if (data2.kembali < 0)
  246.     {
  247.     data2.kurang=data2.kembali*(-1);
  248.     cout<<"\nMaaf uang Anda kurang "<<data2.kurang<<endl;
  249.     }
  250.     else
  251.     {cout<<"\nUang kembali: "<<data2.kembali;}
  252.     cout<<endl;
  253.  
  254.  cout<<"------------------------------------------------------"<<endl;
  255.  cout<<"             HARGA SUDAH TERMASUK PPN"<<endl;
  256.  cout<<"------------------------------------------------------"<<endl;
  257.  cout<<"          TERIMA KASIH ATAS KUNJUNGAN ANDA"<<endl;
  258.  cout<<"------------------------------------------------------"<<endl;
  259.  
  260.  
  261.  cout<<"\n Apakah anda ingin melakukan transaksi lagi ? [Y/T]";
  262.  cin>>lagi;
  263.  
  264. }while(lagi=='Y'||lagi=='y');
  265.  
  266.  
  267.  getch();
  268.  
  269. }
Advertisement
Add Comment
Please, Sign In to add comment