make the variables global and don't pass any parameters. An alternative (and better) is to make a c++ class to hold data and associated methods.
[edit]Note: I did not run your program. Only made it compile without errors. :rolleyes: [/edit]
#include <iostream>
using namespace std;
void DisplayMenu(void);
void Enter_Inventory();
int Display_Inventory();
void Purchase_Soda();
int inventory_number_coke=0;
int inventory_number_pepsi=0;
int inventory_number_cd=0;
int inventory_number_hires=0;
int main()
{
const char SENTINEL = 'Q';
char Choice;
do
{
DisplayMenu();
cin >> Choice;
cout << " " << endl;
switch (Choice)
{
case 'E': case 'e':
void Enter_Inventory();
break;
case 'P': case 'p':
void Purchase_Soda();
break;
case 'S': case 's':
cout << "This is sell" << endl;
break;
case 'D': case 'd':
cout << "This is display" << endl;
break;
default:
cout << "You typed in your entry wrong! Please choose again." << endl;
}
} while (Choice != SENTINEL);
return 0;
}
void DisplayMenu(void)
{
cout << "(E)nter inventory" << endl;
cout << "(P)urchase soda" << endl;
cout << "(S)ell soda" << endl;
cout << "(D)isplay inventory" << endl;
cout << "(Q)uit program" << endl;
cout << " " << endl;
cout << "Please choose by typing the first letter of your choice below." << endl;
cout << " " << endl;
cout << "Choice? ";
}
void Enter_Inventory()
{
int product_value;
int INC, INP, INCD, INH;
cout << "Enter the product number of the inventory you want to submit!" << endl;
cin >> product_value;
cout << "Please enter the number of cases" << endl;
cout << " " << endl;
if (product_value == 1)
{
INC = Display_Inventory();
cin >> INC;
}
else if (product_value == 2)
{
INP = Display_Inventory();
cin >> INP;
}
else if (product_value == 3)
{
INCD = Display_Inventory();
cin >> INCD;
}
else if (product_value == 4)
{
INH = Display_Inventory();
cin >> INH;
}
else
{
cout << "Please re-type selection" << endl;
}
}
int Display_Inventory()
{
cout << "|----------------------------------------|" << endl;
cout << "| Product---- Name ----# of cases--|" << endl;
cout << "| Number ---- ---- --|" << endl;
cout << "|----------------------------------------|" << endl;
cout << "| 1 ---- Coca-Cola ---- " << inventory_number_coke << " --|" << endl;
cout << "|----------------------------------------|" << endl;
cout << "| 2 ---- Pepsi ---- " << inventory_number_pepsi << " --|" << endl;
cout << "|----------------------------------------|" << endl;
cout << "| 3 ---- Canada Dry ---- " << inventory_number_cd << " --|" << endl;
cout << "|----------------------------------------|" << endl;
cout << "| 4 ---- Hires ---- " << inventory_number_hires << " --|" << endl;
cout << "|----------------------------------------|" << endl;
return inventory_number_coke, inventory_number_pepsi, inventory_number_cd, inventory_number_hires;
}
void Purchase_Soda()
{
cout << "|----------------------------------------|" << endl;
cout << "| Product---- Name ----# of cases--|" << endl;
cout << "| Number ---- ---- --|" << endl;
cout << "|----------------------------------------|" << endl;
cout << "| 1 ---- Coca-Cola ---- " << inventory_number_coke << " --|" << endl;
cout << "|----------------------------------------|" << endl;
cout << "| 2 ---- Pepsi ---- " << inventory_number_pepsi << " --|" << endl;
cout << "|----------------------------------------|" << endl;
cout << "| 3 ---- Canada Dry ---- " << inventory_number_cd << " --|" << endl;
cout << "|----------------------------------------|" << endl;
cout << "| 4 ---- Hires ---- " << inventory_number_hires << " --|" << endl;
cout << "|----------------------------------------|" << endl;
cout << " " << endl;
cout << "How much do you want to purchase?" << endl;
} Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343