Overclock.net banner

1 - 3 of 3 Posts

·
Registered
Joined
·
317 Posts
Discussion Starter #1
I need some help with a C++ project. I am getting two undefined reference errors for two functions and need some help. Maybe someone could point me in the right direction?

It's long but here is the code. Any help would be appreciated.

Code:

Code:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

void menuDisplay(ofstream& outfile, vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered,
             vector<int>& pInStore, vector<int>& pSold, vector<double>& manufPrice,
             vector<double>& sellingPrice, int& itemNumber, string& invName, int& noOrdered, int& pcInStore,
             int& noSold, double& cost, double& sellAt, int& listSize, int& input);

void inData(vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered,
                 vector<int>& pInStore, vector<int>& pSold, vector<double>& manufPrice,
                 vector<double>& sellingPrice, int& itemNumber, string& invName, int& noOrdered, int& pcInStore,
                 int& noSold, double& cost, double& sellAt, int& listSize, int& input);

void sellItem(vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered,
                 vector<int>& pInStore, vector<int>& pSold, vector<double>& manufPrice,
                 vector<double>& sellingPrice, int& itemNumber, string& invName, int& noOrdered, int& pcInStore,
                 int& noSold, double& cost, double& sellAt, int& listSize);

void printReport(ofstream& outfile, vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered,
             vector<int>& pInStore, vector<int>& pSold, vector<double>& manufPrice,
             vector<double>& sellingPrice, int& itemNumber, string& invName, int& noOrdered, int& pcInStore,
             int& noSold, double& cost, double& sellAt, int& listSize);

int seqSearch(vector<int>& itemNum, int& listSize, int& searchItem);

int main()
{
    vector<int> invNumber;
    vector<string> invDesc;
    vector<int> pcsOrdered;
    vector<int> pcsInStore;
    vector<int> amtSold;
    vector<double> manufacturePrice;
    vector<double> sellAtPrice;
    int itemNo, pcOrdered, noInStore, numberSold;
    double manuPrice, retail;
    string name;
    int lSize;
    int in;
    ofstream out;
    lSize = invNumber.size();

    menuDisplay(out, invNumber, invDesc, pcsOrdered, pcsInStore, amtSold, manufacturePrice,
                sellAtPrice, itemNo, name, pcOrdered, noInStore, numberSold, manuPrice, retail, lSize, in );

        cin.ignore();
        cin.get();
        return 0;
}

void menuDisplay(ofstream& outfile, vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered,
             vector<int>& pInStore, vector<int>& pSold, vector<double>& manufPrice,
             vector<double>& sellingPrice, int& itemNumber, string& invName, int& noOrdered, int& pcInStore,
             int& noSold, double& cost, double& sellAt, int& listSize, int& input)
{
    int loop = 0;
    int pos = 0;
   // ofstream outfile; // these were shaodows of parameters
   // char input;
    //int listSize = 0;
    //vector<string> itemID;
   // vector<string> itemName;
    //vector<int> pOrdered;
    ///vector<int> pInStore;
    //vector<int> pSold;
    //vector<double> manufPrice;
    //vector<double> sellingPrice;
   // vector<int> itemNum;
    //vector<string> itemDesc;
    //vector<int> pcsInStore;
    //vector<int> numSold;
    //vector<double> sellPrice;
    //int itemNo;
    //string invName;
   // int noOrdered;
   // int pcInStore;
   // int noSold;
   // double cost;
   // double sellAt;

       cout << "1. Search inventory" << endl;
       cout << "2. Place order. " << endl;
       cout << "3. Print Report. " << endl;
       cout << "0. Quit. " << endl;
       cin >> input;

    while (loop < 1)
    {
        switch (input)
            {
                case '1':
                    //Function for searcning
                    inData(itemID, itemName, pOrdered, pInStore, pSold, manufPrice, sellingPrice,
                           itemNumber, invName, noOrdered, pcInStore, noSold, cost, sellAt, listSize, input);
                    break;
                case '2':
                    //Function for ordering
                    sellItem(itemID, itemName, pOrdered, pInStore, pSold, manufPrice, sellingPrice,
                              itemNumber, invName, noOrdered, pcInStore, noSold, cost, sellAt, listSize);
                    break;
                case '3':
                    //funtion for Printing report.
                outfile.open("FriendlyHardwareInventory.txt");
                printReport(outfile, itemID, itemName, pOrdered, pInStore, pSold, manufPrice, sellingPrice,
                            itemNumber, invName, noOrdered, pcInStore, noSold, cost, sellAt, listSize);
                    break;
                case '0':
                    return;
                default:
                    cout << "Please use 1,2,3 for input. 0 to Quit. ";
            }
            cin >> input;
    }

        return;
}

void inData(vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered,
                 vector<int>& pInStore, vector<int>& pSold, vector<double>& manufPrice,
                 vector<double>& sellingPrice, int& itemNumber, string& invName, int& noOrdered, int& pcInStore,
                 int& noSold, double& cost, double& sellAt, int& listSize)
{
    int choice = 0;
    int pos = 0;
    int loc = 0;
    int input = 0;
    int searchChoice = 0;
    int searchItem;
    char answer;
    bool found = true;
    bool newEntry = true;

     while (newEntry)// loop for more entries
    {
        // choices for user
        cout << "To enter an inventory item, press 1." << endl;
        cout << "To search for an existing inventory item, press 2." << endl;
        cout << "To change the price of an existing inventory item, press 3." << endl;

        cin >> choice;

        // switch to determine what kind of input
        switch (choice)
        {
               case 1:// takes in all information for a new inventory item
                    cout << "Enter inventory item number." << endl;
                    cin >> itemNumber;
                    pos = seqSearch(itemID, listSize, searchItem);

                    if (pos == -1)
                    {
                       itemID.push_back(itemNumber);
                       cout << "Enter item name." << endl;
                       cin >> invName;
                       itemName.push_back(invName);
                       cout << "Enter number of pieces ordered." << endl;
                       cin >> noOrdered;
                       pOrdered.push_back(noOrdered);
                       pInStore.push_back(noOrdered);
                       cout << "Enter the manufactures price." << endl;
                       cin >> cost;
                       manufPrice.push_back(cost);
                       sellAt = cost + (cost * .25);// determines selling price for a 25% mark-up
                       sellingPrice.push_back(sellAt);
                       cout << sellAt << endl;
                       break;
                   }
                   else // takes information for items already in inventory

                       cout << "Enter the number of pieces ordered." << endl;
                       cin >> noOrdered;
                       pOrdered[loc] = noOrdered;
                       pInStore[loc] += noOrdered;
                       cout << "Enter the manufactures price." << endl;
                       cin >> cost;
                       manufPrice[loc] = cost;
                       sellAt = cost + (cost * .25);
                       sellingPrice[loc] = sellAt;
                       cout << sellAt << endl;

                       break;

                 case 2:
                 {
                      cout << "Enter Item Number." << endl;
                      cin >> itemNumber;

                      seqSearch(itemID, listSize, searchItem);

                      cout << "Found:" << endl;
                      cout << "Item Number" << setw(10) << "Item Name" << setw(11) << "No. Ordered" << setw(10) <<
                              "In Stock" << setw(15) << "Manufacturer's Price" << setw(13) << "Selling Price" << endl;
                      cout << itemID[loc] << setw(12) << itemName[loc] << setw(12) << pOrdered[loc] <<
                              setw(12) << pInStore[loc] << setw(12) << manufPrice[loc] << setw(12) << sellingPrice[loc] << endl;
                      break;
                 }
                 case 3:// code to just change a price of an existing item
                 {
                      cout << "Enter the item number" << endl;
                      cin >> itemNumber;
                      seqSearch(itemID, listSize, itemNumber);
                      cout << "Enter new manufacturers price." << endl;
                      cin >> cost;
                      manufPrice[loc] = cost;
                      sellAt = cost + (cost * .25);
                      sellingPrice[loc] = sellAt;
                      cout << sellAt;
                      break;
                }

           default:
                cout << "You have not entered a valid choice." << endl;
           }

           // code to see if there is another new entry.
           cout << "Do you want to enter another item number? Y or N" << endl;
           cin >> answer;
           if (answer == 'Y' || answer == 'y')
               newEntry = true;
           else
               cout << "Do you want to print a report now?" << endl;
               cin >> answer;
               if (answer == 'y' || answer == 'Y')
                  input = 3;
               else
                  input = 0;
    }
}

// function created by Cletis Jones
int sellItem(vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered,
                 vector<int>& pInStore, vector<int>& pSold, vector<double>& manufPrice,
                 vector<double>& sellingPrice, int& itemNumber, string& invName, int& noOrdered,
                 double& noSold, double& sellAt, int& listSize)
{

    int amtBought;
    double cash;
    char verifyItem;
    int i;
    int index = 0;
   // int itemNumber;

    for (i = 0; i < 5; i++)
    {

     //Finding out what's being sold.
        cout << "What itemID is being purchased? ";
        cin >> itemNumber;

        for (i = 0; i < listSize; i++)
        {
        index = seqSearch(itemID, listSize, itemNumber);// changed this

        if (index != -1)
        {
            cout << "You are selling " << itemName[i] << ", which costs $" << sellingPrice[i]
                << ".  Is this correct? (Y/N)" << endl;
            cout << endl;
            cin >> verifyItem;
        }
        else
        {
            cout << "Not a vaild entry.";
        }

            if (verifyItem == 'N' || verifyItem == 'n')
            {
                cout << "What item number is being purchased? " << endl;
                cin >> itemNumber;
            }

            cout << "How many items are being purchased? " << endl;
            cin >> amtBought;

            if (amtBought < 1)

                    cout << "None of this item is being purchased!" << endl;

                else

                    if (pInStore[i] < amtBought)
                        cout << "There are not enough of this item to sell!  Up to " << pInStore[i] << " can be sold." << endl;

            }

        }
}

//Aron Gilbert-wk 6 Group B assig-printReport function
void printReport (ofstream& outfile, vector<int>& itemNum, vector<string>& itemName, vector<int>& pOrdered,
             vector<int>& pInStore, vector<int>& pSold, vector<double>& manufPrice,
             vector<double>& sellingPrice, int& itemNumber, string& invName, int& noOrdered, int& pcInStore,
             int& noSold, double& cost, double& sellAt, int& listSize)
{

    double totalInventory = 0;
    int totalItems = 0;

    outfile.open("FriendlyHadwareInventory.txt");

    outfile << "     Friendly Harware Store     ";
    outfile << endl;
    outfile << "itemID ";
    outfile << "itemName ";
    outfile << "pOrdered ";
    outfile << "pInStore ";
    outfile << "pSold ";
    outfile << "manufPrice ";
    outfile << "sellingPrice " << endl;

    for(int index = 0; index < listSize; index++)
        {
            outfile << left;
            outfile << setw(10) << itemName[index] << " ";
            outfile << right;
            outfile << setw(10) << pOrdered[index] << " ";
            outfile << setw(10) << pInStore[index] << " ";
            outfile << setw(7) << pSold[index] << " ";
            outfile << setw(12) << manufPrice[index] << " ";
            outfile << setw(15) << sellingPrice[index] << " " << endl;
            outfile << endl;
        }

        for (int i = 0; i < listSize; i++)

            totalInventory = totalInventory + pInStore[i] * sellingPrice[i];
        for (int j = 0; j < listSize; j++)
            totalItems = totalItems + pInStore[j] - pSold[j];

    cout << "Total Inventory is  " << totalInventory << "$         " <<endl;
    cout << "Total Items in Inventory is  " << totalItems << "         " << endl;
}

// function used to search item numbers
int seqSearch(vector<int>& itemNum, int& listSize, int& searchItem)
{
    int loc;
    bool found = false;

    loc = 0;

    while (loc < listSize && !found)
        if (itemNum[loc] == searchItem)
            found = true;
        else
            loc++;
    if (found)
        return loc;
    else
        return -1;
}
 
1 - 3 of 3 Posts
Top