I am writing a program using functions and I am already to compile when I get a lot of these errors. Can anyone tell what it means?
Error 2 error C2601: 'groceriesMenu' : local function definitions are illegal c:\users\kimberly\documents\visual studio 2012\projects\practice 14\practice 14\source.cpp 98 1 Practice 14
i decided to post the code i have. So you can see what i am dealing with. We are to write a program using functions. Our model is a store with three departments in those departments are three more options to choose from.
#include <iostream>
#include <string>
using namespace std;
int main()
{
//Function prototype
void displayMenu();
int getChoice();
void groceryMenu();
void clothingMenu();
void produceMenu();
do
{ displayMenu(); // Displays main menu.
choice = getChoice();
cout << "Would you like to try again?";
cin >> again;
}while(again == 'y' || again == 'Y');
system("pause");
return 0;
/****************************************************
* Display Menu *
* This Function clears the screen and then diplays *
* the menu choices. Then using if statements for *
* the users choice and calls the correct function. *
****************************************************/
void displayMenu()
{
system("cls");
cout << "Welcome to Your Community Grocery Store" << endl;
cout << "What area will you be shopping in today?"<<
cout << "1. Grocery" << endl;
cout << "2. CLothing" << endl;
cout << "3. Produce" << endl;
cout << "4. Quit" << endl;
cin >> choice;
if (choice == 1)
{void groceriesMenu();
}
if (choice == 2)
{void clothingMenu();
}
if (choice == 3)
{void clothingMenu();
}
}
/************************************************
* Get Choice
* This function inputs , validates, and returns *
the user's menu choice. *
************************************************/
int getChoice();
{
int choice;
cin >> choice;
while (choice < 1 || choice >4)
{ cout << "The only valid choices are 1-4." << endl;
cin >> choice;
}
return choice;
}
/******************************************
* Grocery menu *
* This function diplays the groceries *
* menu. *
******************************************/
void groceriesMenu();
{system("cls");
cout << "You have chosen the groceries menu." << endl;
cout << "Choose One:" << endl;
cout << "1. Beef" << endl;
cout << "2. Pork" << endl;
cout << "3. Chicken " << endl;
cin >> choice;
if (choice ==1)
{cout << " Beef is $1.50 a pound. How many pounds would you like?" << endl;
cin >> lbs;
cost = beef * lbs;
price = cost * .07;
cout << "Your cost is $" << price << ". This isnludes a 7% sales tax." << endl;
}
if (choice == 2)
{cout << "Pork is $1.75 a pound. How many pounds would you like?" << endl;
cin >> lbs;
cost = pork * lbs;
price = cost * .07;
cout << "The cost is $" << price << ". This incudes a 7% sales tax." << endl;
}
if (choice == 3)
{cout << "Chicken is $0.89 a pound. How many pounds would you like?" << endl;
cin >> lbs;
cost = chicken * lbs;
price = cost * .07;
cout << "The cost is $" << price << ". This incudes a 7% sales tax." << endl;
}}
/************************************************
* Get Groceries Choice *
* This function inputs , validates, and returns *
* the user's menu choice. *
************************************************/
void getMenuChoice()
{
int choice;
cin>> choice;
while (choice < 1 || choice >3)
{ cout << "The only valid choices are 1-3" << endl;
cin >> choice;
}
}
/*********************************************
* Clothing menu *
* This function diplays the clothing menu. *
*********************************************/
void clothingMenu()
{system("cls");
cout << "You have chosen the clothing menu." << endl;
cout << "Choose one:" << endl;
cout << "1. Dresses" << endl;
cout << "2. Jeans" << endl;
cout << "3. T-shirts" << endl;
cin >> choice;
if (choice == 1)
{ cout << "Dresses are $15.00 each. How many would you like to purchase?" << endl;
cin >> num; // The number of dresses the user wishes to purchase.
cost = dresses * num;
price = cost * .07;
cout << "The cost is $" << price << ". This incudes a 7% sales tax." << endl;
}
if (choice == 2)
{cout << "Jeans are $9.00 each. How many would you like to purchase?" << endl;
cin >> num;
cost = jeans * num;
price = cost *.07;
cout << "The cost is $" << price << ". This includes a 7% sales tax." << endl;
}
if (choice == 3)
{cout << "The T-shirts are $3.50 each. How many would you like to purchase?" << endl;
cin >> num;
cost = dresses * num;
price = cost * .07;
cout << "The cost is $" << price << ". This includes a 7% sales tax." << endl;
}}
/***********************************************
* Produce Menu *
* This function displays the Produce menu. It *
* gives the user shopping ooptions and allows *
* user input. *
***********************************************/
void produceMenu()
{system("cls");
cout << "You have chosen the clothing menu." << endl;
cout << "Choose one:" << endl;
cout << "1. Apples" << endl;
cout << "2. Oranges" << endl;
cout << "3. Bananas" << endl;
cin >> choice;
if (choice == 1)
{cout << "Apples are $0.59 a pound. How many pounds would you like?" << endl;
cin >> lbs;
cost = apples * lbs;
price = cost *.07;
cout << "The cost is $" << price << ". This includes a 7% sales tax." << endl;
}
if (choice == 2)
{cout << "Oranges are $0.79 a pound. How many pounds would you like?" << endl;
cin >> lbs;
cost = oranges * lbs;
price = cost * .07;
cout << "The cost is $" << price << ". This includes a 7% sales tax." << endl;
}
if (choice == 3)
{cout << "Bananas are $0.29 a pound. How many pounds would you like?" << endl;
cin >> lbs;
cost = bananas * lbs;
price = cost * .07;
cout << "The cost is $" << price << ". This includes a 7% sales tax." << endl;
}}