Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  COCKTAIL
Language: C/C++
Code:
#include <iostream>
#include<string>
#include <iomanip>
#include<fstream>
#include<cstdlib>
using namespace std;
void Registration();
void Order();
void ViewOrder();
void DisplayInfo();
char mainmenu,option;
string name,courseandyear,studentno,campus;
char bookorder,answer;
int reservetrigger=0,infotrigger=0,ordertrigger=0;
int date;
int reservedbook;
double price=0;
int stock1=100, stock2=100, stock3=100, stock4=100, stock5=100 ,stock6=100 ,stock7=100, stock8=100, stock9=100, stock10=100, stock11=100, stock12=100, stock13=100 ,stock14=100 ,stock15=100;
int order1=0, order2=0, order3=0, order4=0 ,order5=0 ,order6=0, order7=0, order8=0, order9=0, order10=0, order11=0, order12=0 ,order13=0 ,order14=0,order15=0;
int main()
{
     cout<<"*******************************************************************"<<endl;     
     cout<<"            Mapua Institute of Technology E-Bookstore"<<endl;     
     while (option!='5')
     {
     cout<<"*******************************************************************"<<endl;     
     cout<<"                    What would you like to do?: "<<endl;
     cout<<"*******************************************************************"<<endl;     
     cout<<"     1. Register."<<endl;
     cout<<"     2. Order a book."<<endl;
     cout<<"     3. Check information."<<endl;
     cout<<"     4. View Order."<<endl;
     cout<<"     5. Quit"<<endl;
     cout<<"*******************************************************************"<<endl;     
     cin>>option;
     switch(option)
     {
          case '1':
               Registration();
              break;
          case '2':
               Order();
               break;
          case '3':
               DisplayInfo();
               break;
          case '4':
               ViewOrder();
               break;
          case '5':
              cout<<"n     Thank you and have a nice day!!!"<<endl;
               break;
          default:
               cout<<"n     Enter 1,2,3,4,5 only please."<<endl;
               break;
               
               
     }
}
     return 0;
}
void Registration()
{
     system("CLS");
     cout<<"*******************************************************************"<<endl;     
     cout<<"              Please enter the following: "<<endl;
     cout<<"*******************************************************************"<<endl;     
     cout<<"n     Name           : ";
     cin.ignore();
     getline(cin,name);
     cout<<"n     Student Number : ";
     getline(cin,studentno);
     cout<<"n     Course and Year: ";
     getline(cin,courseandyear);
     cout<<"n     Campus/Location: ";
     getline(cin,campus);
     cout<<"*******************************************************************"<<endl;     
     price=0;
     reservetrigger=1;
     infotrigger=1;
     order1=0, order2=0, order3=0, order4=0 ,order5=0 ,order6=0, order7=0, order8=0, order9=0, order10=0, order11=0, order12=0 ,order13=0 ,order14=0,order15=0;
}
void Order()
{
     
     system("CLS");
     bookorder=='y';
     if (reservetrigger==1)

     {
     do 
     {
          cout<<"*******************************************************************"<<endl;
     cout<<"n     Please choose a book to reserve: "<<endl;
     cout<<"************************************************************************"<<endl;     
     cout<<"                             BOOK LIST: "<<endl;
     cout<<"************************************************************************"<<endl;     
     cout<<"          Title                                Price           Stock"<<endl;
     cout<<"************************************************************************"<<endl;     
     cout<<"1. Wiley Plus Algebra and Trigonometry       Php 1700.00        "<<stock1 <<endl;
     cout<<"2. General Chemistry I                       Php 1850.00     "<<stock2 <<endl;               
     cout<<"3. Solid Mensuration                         Php 300.00       "<<stock3 <<endl; 
     cout<<"4. Chemistry Laboratory Manual I             Php 155.00             "<<stock4 <<endl; 
     cout<<"5. Filipino: Wika at Literatura              Php 350.00          "<<stock5 <<endl; 
     cout<<"6. Understanding Speech                      Php 250.00          "<<stock6 <<endl;
     cout<<"7. Basic Calculus                            Php 1200.00     "<<stock7 <<endl;
     cout<<"8. C++ 360 Degrees                           Php 2000.00     "<<stock8 <<endl;
     cout<<"9. Physical Education Manual                 Php 150.00          "<<stock9 <<endl;
     cout<<"10. Surviving AutoCAD                        Php 370.00          "<<stock10 <<endl;
     cout<<"11. Mapua 101: Rules and Regulations         Php 120.00          "<<stock11 <<endl;
     cout<<"12. Greek Mythology I                        Php 340.00          "<<stock12 <<endl;
     cout<<"13. English: Language and Literature         Php 500.00          "<<stock13 <<endl;
     cout<<"14. Drawing I: Guidelines and Basics         Php 200.00          "<<stock14 <<endl;
     cout<<"15. Philippine History                       Php 300.00          "<<stock15 <<endl;     
     cout<<"************************************************************************"<<endl;     
     cin>>reservedbook;
     switch (reservedbook)
     {
          case 1:
          {
          price=price+1700;
          stock1=stock1-1;
        order1=order1+1;
          break;
         }
         case 2:
          {
          price=price+1850;
          stock2=stock2-1;
          order2=order2+1;
          break;
         }
         case 3:
          {
          price=price+300;
          stock3=stock3-1;
          order3=order3+1;
          break;
         }
         case 4:
          {
          price=price+155;
          stock4=stock4-1;
          order4=order4+1;
          break;
         }
         case 5:
          {
          price=price+350;
          stock5=stock5-1;
          order5=order5+1;
          break;
         }
         case 6:
          {
          price=price+250;
          stock6=stock6-1;
          order6=order6+1;
          break;
         }
         case 7:
          {
          price=price+1200;
          stock7=stock7-1;
          order7=order7+1;
          break;
         }
         case 8:
          {
          price=price+2000;
          stock8=stock8-1;
          order8=order8+1;
          break;
         }
         case 9:
          {
          price=price+150;
          stock9=stock9-1;
          order9=order9+1;
          break;
         }
         case 10:
          {
          price=price+370;
          stock10=stock10-1;
          order10=order10+1;
          break;
         }
         case 11:
          {
          price=price+120;
          stock11=stock11-1;
          order11=order11+1;
          break;
         }
         case 12:
          {
          price=price+340;
          stock12=stock12-1;
          order12=order12+1;
          break;
         }
         case 13:
          {
          price=price+500;
          stock13=stock13-1;
          order13=order13+1;
          break;
         }
         case 14:
          {
          price=price+200;
          stock14=stock14-1;
          order14=order14+1;
          break;
         }
         case 15:
          {
          price=price+300;
          stock15=stock15-1;
          order15=order15+1;
          break;
         }
         default:
         {
         cout<<"n     Enter 1,2,3,4,5,6,7,8,9,10,12,13,14,15 only please."<<endl;
         break;
          }     
     }
     ordertrigger=1;
     cout<<"n     Do you wish to reserve another book?[y/n]"<<endl;
     cin>>bookorder;
}while(bookorder=='y'||bookorder=='Y');
cout<<"n     Do you wish to view the order/s you made?[y/n]"<<endl;
cin>>answer;
if (answer=='y'||answer=='Y')
{
     ViewOrder();
}
cout<<"n     Do you wish to go to the main menu?[y/n]"<<endl;
cin>>option;
}
    else 
    {
    cout<<"n    Please Register first before reserving a book. Thank you :)"<<endl;
     }
}
void DisplayInfo()
{
     system("CLS");
     if (infotrigger==1)
     {
     cout<<"*******************************************************************"<<endl;     
     cout<<"                       Student Information"<<endl;
     cout<<"*******************************************************************"<<endl;     
     cout<<"   Name           : "<<name<<endl;
     cout<<"   Course And Year: "<<courseandyear<<endl;
     cout<<"   Student Number : "<<studentno<<endl;
     cout<<"   Campus/Location: "<<campus<<endl;
     cout<<"*******************************************************************"<<endl;     
    }
    else
    {
    cout<<"n     You have not yet registered :("<<endl;
    cout<<"n    Please register first. Thank you :)"<<endl;
     }
}
void ViewOrder()
{
     system("CLS");
     cout<<showpoint<<fixed;
    cout<<setprecision(2);
     if(ordertrigger==1)
     {
     cout<<"*******************************************************************"<<endl;     
     cout<<"                            ORDER SLIP"<<endl;
     cout<<"*******************************************************************"<<endl;     
     cout<<"   Name           : "<<name<<endl;
     cout<<"   Course And Year: "<<courseandyear<<endl;
     cout<<"   Student Number : "<<studentno<<endl;
     cout<<"   Campus/Location: "<<campus<<endl;
     cout<<"*******************************************************************"<<endl;     
     cout<<"     Name of Book/s Ordered              Quantity "<<endl;  
     cout<<"*******************************************************************"<<endl;     
     if (order1>0)
     {
     cout<<"Wiley Plus Algebra and Trigonometry         "<<order1<<endl;
     }
     if (order2>0)
     {
     cout<<"General Chemistry I                         "<<order2<<endl;
     }
     if (order3>0)
     {
     cout<<"Solid Mensuration                           "<<order3<<endl;
     }
     if (order4>0)
     {
     cout<<"Chemistry Laboratory Manual I               "<<order4<<endl;
     }
     if (order5>0)
     {
     cout<<"Filipino: Wika at Literatura                "<<order5<<endl;
     }
     if (order6>0)
     {
     cout<<"Understanding Speech                        "<<order6<<endl;
     }
     if (order7>0)
     {
     cout<<"Basic Calculus                              "<<order7<<endl;
     }
     if (order8>0)
     {
     cout<<"C++ 360 Degrees                             "<<order8<<endl;
     }
     if (order9>0)
     {
     cout<<"Physical Education Manual                   "<<order9<<endl;
     }
     if (order10>0)
     {  
     cout<<"Surviving AutoCAD                           "<<order10<<endl;
     } 
     if (order11>0)
     {
     cout<<"Mapua 101: Rules and Regulations            "<<order11<<endl;
     }
     if (order12>0)
     {
     cout<<"Greek Mythology I                           "<<order12<<endl;
     }
     if (order13>0)
     {
     cout<<"English: Language and Literature            "<<order13<<endl;
     }
     if (order14>0)
     {
     cout<<"Drawing I: Guidelines and Basics            "<<order14<<endl;
     }
     if (order15>0)
     {
     cout<<"Philippine History                          "<<order15<<endl;
     }
     cout<<"*******************************************************************"<<endl;     
     cout<<"                     Total Cost: Php "<<price<<endl;
     cout<<"*******************************************************************"<<endl;     
    }
    else if (ordertrigger==0)
    {
         cout<<"n    You haven't made an order yet. Please make an order first thank you."<<endl;
     }
}

          
Comments: