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;
}
//------------------------------------------------------------------------------------------------------------