[#include <iostream.h>
void initialize(int& coke, int& pepsi, int& dry, int& hires);
void sales_type(char& sale_type, int& brand, int& quantity, int& coke, int& pepsi, int& dry, int& hires);
//void clearline();
void purchased(int& brand, int& quantity, int& coke, int& pepsi, int& dry, int& hires);
void sell(int& brand, int& quantity, int& coke, int& pepsi, int& dry, int& hires);
void display_inventory(int& coke, int& pepsi, int& dry, int& hires);
int get_total_coke(int& coke, int& coke_add);
int get_total_pepsi(int& _pepsi, int& pepsi_add);
int get_total_dry(int& dry, int& dry_add);
int get_total_hires(int& hires, int& hires_add);
void main()
{
int coke = 0;
int pepsi = 0;
int dry = 0;
int hires = 0;
int brand;
int quantity;
char sale_type;
initalize(coke, pepsi, dry, hires);
sales_type(s_type, brand, quantity, coke, pepsi, dry, hires);
purchase(brand, quanitity, coke, pepsi, dry, hires);
sell(brand, quantity, coke, pepsi, dry, hires);
display_inventory(coke, pepsi, dry, hires);
//clearline();
}
void initialize(int& coke, int& pepsi, int& dry, int& hires)
{
int coke_add;
int pepsi_add;
int dry_add;
int hires_add;
cout << "Please enter the inventory for each item "<< endl;
cout << "Enter the number of Coca-Cola cases: ";
cin >> coke_add;
while (cin.fail())
{
cin.clear();
cin.ignore(cin.fail());
cout << "Invalid input...please re-enter"<< endl;
cout << "\nEnter the number of Coca-Cola cases: ";
cin >> coke_add;
}
coke+= get_total_coke(coke, coke_add);
cout << "\nEnter the number of Pepsi cases: ";
cin >> pepsi_add;
while (cin.fail())
{
cin.clear();
cin.ignore();
cout << "Invalid input...please re-enter" << endl;
cout << "\nEnter the number of Pepsi cases: " << endl;
cin >> pepsi_add;
}
pepsi+= get_total_pepsi( pepsi, pepsi_add);
cout << "\nEnter the number of Canada Dry cases: ";
cin >> dry_add;
while (cin.fail())
{
cin.clear();
cin.ignore();
cout << "Invalid input...please re-enter" << endl;
cout << "\nEnter the number of Canada Dry cases: " << endl;
cin >> dry_add;
}
dry+= get_total_dry(dry, dry_add);
cout << "\nEnter the number of Hires cases: ";
cin >> hires_add;
while (cin.fail())
{
cin.clear();
cin.ignore();
cout << "Invalid input...please re-enter" << endl;
cout << "\nEnter the number of Hires cases: " << endl;
cin >> hires_add;
}
hires+= get_total_hires(hires, hires_add);
//clearline();
}
void sales_type(char& sale_type, int& brand, int& quantity, int& coke, int& pepsi,int& dry, int& hires)
{
cout << "\nPlease enter the command that you want to do: ";
cin >> sale_type;
cout << "\nPlease enter the brand that you would like to purchase: ";
cin >> brand;
cout << "\nPlease enter the quantity of the brand you would like to purchase: ";
cin >> quantity;
switch(sale_type)
{
case 'E': case 'e':
initialize(coke, pepsi, dry, hires);
break;
case 'P': case 'p':
purchased(brand, quantity, coke, pepsi, dry, hires);
break;
case 'S': case 's':
sell(brand, quantity, coke, pepsi, dry, hires);
break;
case 'D': case 'd':
display_inventory(coke, pepsi, dry, hires);
break;
case 'Q': case 'q':
cout << "Thank you and have a nuce day!!!" << endl;
break;
}
}
void purchase(int& brand, int& quantity, int& coke, int& pepsi, int& dry, int& hires)
{
while(brand >= 1 && brand <= 4)
{
switch(brand)
{
case '1':
coke = coke + quantity;
cout << "Inventory updated..." << endl;
break;
case '2':
pepsi = pepsi + quantity;
cout << "Inventory updated..." << endl;
break;
case '3':
dry = dry + quantity;
cout << "Inventory updated..." << endl;
break;
case '4':
hires = hires + quantity;
cout << "Inventory updated..." << endl;
break;
default:
cout << "bbThe action you requested is invalid.nothing has been done..." << endl;
}
}
cin.clear();
cin.ignore();
cout << "\nThe action you requested is invalid.nothing has been done..." << endl;
}
void sell(int& brand, int& quantity, int& coke, int& pepsi, int& dry, int& hires)
{
while (brand >= 1 && brand <= 4)
{
switch(brand)
{
case '1':
while (!cin.fail() && quantity > 0)
if(quantity > coke)
{
cout << "Insufficient inventory to fill sell order, nothing changed." << endl;
}
else coke = coke - quantity;
cout << "Inventory updated...";
break;
case '2':
while (!cin.fail() && quantity > 0)
if(quantity > pepsi)
{
cout << "Insufficient inventory to fill sell order, nothing changed." << endl;
}
else pepsi = pepsi - quantity;
cout << "Inventory updated...";
break;
case '3':
while (!cin.fail() && quantity > 0)
if(quantity > dry)
{
cout << "Insufficient inventory to fill sell order, nothing changed." << endl;
}
else dry = dry - quantity;
cout << "Inventory updated...";
break;
case '4':
while (!cin.fail() && quantity > 0)
if(quantity > hires)
{
cout << "Insufficient inventory to fill sell order, nothing changed." << endl;
}
else hires = hires - quantity;
cout << "Inventory updated...";
break;
default:
cout << "ccThe action you requested is invalid...nothing has been done" << endl;
}
}
}
int get_total_coke(int& coke, int& coke_add)
{
while (coke_add < 0)
{
cout << " The action you have requested is invalid....nothing changed." << endl;
cout << " Please enter the amount of Coke cases: "<<endl;
cin.clear();
cin >> coke_add;
}
return coke_add;
}
int get_total_pepsi(int& pepsi, int& pepsi_add)
{
while (pepsi_add<0)
{
cout << " The action you have requested is invalid....nothing changed." << endl;
cout << " Please enter the amount of Pepsi cases: " << endl;
cin.clear();
cin >> pepsi_add;
}
return pepsi_add;
}
int get_total_dry(int& dry, int& dry_add)
{
while (dry_add<0)
{
cout << " The action you have requested is invalid....nothing changed." << endl;
cout << " Please enter the amount of Canada Dry cases: " << endl;
cin.clear();
cin >> dry_add;
}
return dry_add;
}
int get_total_hires(int& hires, int& hires_add)
{
while (hires_add<0)
{
cout << " The action you have requested is invalid....nothing changed." << endl;
cout << " Please enter the amount of Hires cases: " << endl;
cin.clear();
cin >> hires_add;
}
return hires_add;
}
void display_inventory(int& coke, int& pepsi, int& dry, int& hires)
{
cout << "Present inventory"<< endl;
cout << "Coke--"<< coke << endl;
cout << "Pepsi--"<< pepsi << endl;
cout << "Canada Dry--" << dry << endl;
cout << "Hires--" << hires << endl;
}
This is the error message i keep getting and i dont know what it means
$ c++ 1.cpp
Undefined first referenced
symbol in file
purchased(int &, int &, int &, int &, int &, int &)/var/tmp/ccYQ5XO1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
$