New Posts  All Forums:Forum Nav:

C++ project help

post #1 of 3
Thread Starter 
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:
#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;
}
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
post #2 of 3
your function prototypes need to match the function exactly. this includes matching the argument names and order exactly.

inData, sellItem, and printReport do not match and need to be changed.

in the future, use the code tags so that your code formats nicely. thumb.gif
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Reply
post #3 of 3
Thread Starter 
Thanks
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7 950 Asus P6X58D-E Gigabyte GTX 770  12 GB GSkill 
Hard DriveOptical DriveOSMonitor
Seagate 1TB, Samsung 2TB TSSTcorp Windows 7 home Premium x64 Asus 24" 1920*1080 x 2 
KeyboardPowerCaseMouse
WASD XFX 650 watt Cooler Master HAF 932 Logitech G500 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming