wrong menu at the start up

This is a discussion on wrong menu at the start up within the C++ Programming forums, part of the General Programming Boards category; my assignment is notworking well it is out putting the wrong menu at the start up can someone pleaaseeeeeeeeeeee helpme ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    1

    wrong menu at the start up

    my assignment is notworking well it is out putting the wrong menu at the start up can someone pleaaseeeeeeeeeeee helpme is urgent
    Code:
    #include<iostream>
    #include<string>
    #include<cmath>
    
    using namespace std;
    
    
    int option;
    int employeeMenu();
    void employeeSalary();
    int displayFood();
    
    int employeeMenu()
    {
        system("color B");
    	int employeeoption;
    
    	
        cout << "\t\t     CADOGAN'S SERVICES MINIATURE GOLF COURSE\n\n";    
        cout << "\t\t[1.]Calculate Employee Salary\n\n";
        cout << "\t\t[2.]Exit\n\n";
    
    	cout << "Enter employee option:";
    	cin >> employeeoption;
    
    	return employeeoption;
    }
    //--------------------------------------------------------------------------------------
    void employeeSalary()
    {
     system("cls");    
     string name,dummy;
    //employee name
    double hours,rate,pay,code;
    //count the employees
    cout.setf(ios::fixed,ios::floatfield);
    cout.precision(2);
    //set decimal precision
    cout << "Please enter an employee code (between 100 and 200 inclusively): ";
    cin >> code;
    while (code <  100 ||code > 201)
    {
          cout<<"Invalid Employee Code!"<<endl;
           system("pause");
           system("cls");
          cout << "Please enter an employee code(between 100 and 200 inclusively): ";
          cin >> code;
    }
    getline(cin, dummy);      
    cout << "Please enter an employee name: ";
    getline(cin, name);
    //read name
    cout << "Please enter the hours worked: ";
    cin >> hours;
    //read hours worked
    cout << "Please enter the rate of pay: ";
    cin >> rate;
    //read rate of pay
    pay = hours * rate;
    //calculate pay
    cout << "                        "<<endl;
    cout << "                        "<<endl;
    cout << "Employee:" << name <<endl;
    cout<<"Employee Earning: $" << pay << endl;
    system("pause");
    system("cls");
    }
    void fish()
    {
              double fishQuant;
              double fishTotal;
    		  cout<<"How many fish do you want:";
    		  cin >>fishQuant;
              fishTotal=fishQuant*8.00;
    		  cout<<"Total Cost:$"<<fishTotal<<endl;
    		  
    
    }
    void hot()
     {
              double hotQuant;
              double hotTotal;
              cout<<"How many hotdogs do you want:";
              cin>>hotQuant;      
              hotTotal=hotQuant*4.50;
    		  cout<<"Total Cost:$"<<hotTotal<<endl;
    		
    	
    }   
    		  
    void chick()
     {
              double chickQuant;
              double chickTotal;
              cout<<"How many chicken an chips do you want:";
              cin>>chickQuant;
              chickTotal=chickQuant*7.00;
              cout<<"Total Cost:$"<<chickTotal<<endl;
    		 
    }
       
      
    void sand()
    {
              double sandQuant;
              double sandTotal;
              cout<<"How many sandwiches do you want:";
              cin>>sandQuant;      
              sandTotal=sandQuant*3.95;
              cout<<"Total Cost:$"<<sandTotal<<endl;
    		  
    };
    
    void drnk()
    {
           double drnkQuant;
           double drnkTotal;
           cout<<"How many drinks do you want:";
           cin>>drnkQuant;
           drnkTotal=drnkQuant*2.00;
           cout<<"Total Cost:$"<<drnkTotal<<endl;
           
    }
     void display()
    {
    
    	int options;
        cout<<" Welcome to Cadogan's Services Minature Golf Course!"<<endl;
        cout<<"Please continue to make all your selections by using the item number on the left"<<endl;
        cout<<"When you are finished type '6' to exit."<<endl;
        cout<<endl;
        cout<<"NOTE: Any selection other than Item# or '6' will result in a crash"<<endl;
        cout<<endl;
        cout<<"                                  MENU                                        "<<endl;
        cout<<"Item# Description                                                        Price"<<endl;
        cout                                                                                  <<endl;
        cout<<"[1] Fish And Chips                                                        8.00"<<endl;
        cout<<endl;
        cout<<"[2] Hotdogs                                                               4.50"<<endl;
        cout<<endl;
        cout<<"[3] Chicken And Chips                                                     7.00"<<endl;
        cout<<endl;
        cout<<"[4] Sandwiches                                                            3.95"<<endl;
        cout<<endl;
        cout<<"[5] Drinks                                                                2.00"<<endl;
        cout<<endl;
    	cout<<"[6] Exit "                                                                      <<endl;
        cout<<endl;
        cout << "Enter option:";
    	cin >> options;
    	
    	
       while (options > 8)
        {
        cout<<"Invalid Option!"<<endl;
        system("pause");
        system("cls");
        cout<<" Welcome to Cadogan's Services Minature Golf Course!"<<endl;
        cout<<"Please continue to make all your selections by using the item number on the left"<<endl;
        cout<<"When you are finished type '6' to exit."<<endl;
        cout<<endl;
        cout<<"NOTE: Any selection other than Item# or '6' will result in a crash"<<endl;
        cout<<endl;
        cout<<"                                  MENU                                        "<<endl;
        cout<<"Item# Description                                                        Price"<<endl;
        cout                                                                                  <<endl;
        cout<<"[1] Fish And Chips                                                        8.00"<<endl;
        cout<<endl;
        cout<<"[2] Hotdogs                                                               4.50"<<endl;
        cout<<endl;
        cout<<"[3] Chicken And Chips                                                     7.00"<<endl;
        cout<<endl;
        cout<<"[4] Sandwiches                                                            3.95"<<endl;
        cout<<endl;
        cout<<"[5] Drinks                                                                2.00"<<endl;
        cout<<endl;
    	cout<<"[6] Exit "                                                                      <<endl;
        cout<<endl;
        cout << "Enter option: ";
        cin >> options;
          
        }
        system("cls");
             if (options == 1)
    			    fish();
    		else
    		 if (options == 2)
                      hot();
    		  else
    		   if (options == 3)
           	        chick();
    	       else
               if (options == 4)
               		 sand();
      		 else
                 if (options == 5)        
                   drnk();
              //endifs
    system("pause");
    system("cls");
         
    }   
    //-----------------------------------------------------------------------------------------
    void displayMenu()
    {
      
        cout << "\n\t\t               MAIN M E N U \n\n";
        cout << "\t\t     CADOGAN'S SERVICES MINIATURE GOLF COURSE\n\n";    
        cout << "\t\tEmployee Salary[1] \n\n";
        cout << "\t\tFood Sales[2]\n\n";
    
    
    }
    //-----------------------------------------------------------------------------------------
    int displaySelection(int opt)
    {
      int menu;
    	if (opt == 1)
    		menu = employeeMenu();
    	else	
    	     if (opt == 2)
    		         display();   
                     menu = 2 ;
              return menu;
    //end ifs
    
    
    }
    
    //-----------------------------------------------------------------------------------------
    int main()
    {
    
        int menu;
        int choice;
        displayMenu();
        cout << "Enter menu option:";	
    	cin  >> choice;
        system("cls");
        
         while (choice !=1 && choice != 2)
         {
            cout<<"Invalid Option Nubmber";
            displayMenu();
            cout << "Enter menu option:";
            cin  >> choice;
            system("cls");
         }
         menu = displaySelection(choice);
          if  (menu == 1)
          {
             employeeSalary();
             menu = employeeMenu();
          }
          else
            if  (menu == 2)
            {
          
                display();
            }
             
        system("PAUSE");
    	return 0;
    }
    //------------------------------------------------------------------------------------------------------------

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Which menu are you getting and which menu do you want?

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Surely the two posts above should be separated from the first N posts, as they are completely unrelated.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,758
    Quote Originally Posted by matsp
    Surely the two posts above should be separated from the first N posts, as they are completely unrelated.
    That's right, so I have moved them to a new thread.

    pini, read the homework policy and follow it.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  3. start menu behavior
    By DavidP in forum Tech Board
    Replies: 3
    Last Post: 06-28-2004, 11:30 AM
  4. Delet Frequency in linked list
    By swishiat.com in forum C Programming
    Replies: 16
    Last Post: 12-13-2003, 01:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21