HELP ME!!!

/* Read from a file called “data.txt”. 
<ID>
<Product>
<Number ordered> <Manufacture Price> <Selling Price>


Example Input:
1111
Dish Washer
20 250.50 550.50
2222
Micro Wave
75 150.00 400.00
3333
Cooking Range 
50 450.00 850.00
4444
Circular Saw
150 45.00 125.00
*/




#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <vector>

using namespace std;

void getData(ifstream& inp, vector<int>& iID, vector<string>& iName, 
             vector<int>& pOrdered, vector<int>& pInStore,
             vector<int>& pSold, vector<double>& manufPrice, 
             vector<double>& sPrice); 
//Define the funciton

void sortData(vector<int>& iID, vector<string>& iName, 
             vector<int>& pOrdered, vector<int>& pInStore,
             vector<double>& manufPrice, 
             vector<double>& sPrice);

int binSearch(vector<string> list, string searchItem);

void menu();
//Define the funciton

void printReport(const vector<int>& iID, const vector<string>& iName, 
             const vector<int>& pOrdered, const vector<int>& pInStore,
             const vector<int>& pSold, const vector<double>& manufPrice, 
             const vector<double>& sPrice);
void makeSale(const vector<string>& iName, vector<int>& pInStore,
              vector<int>& pSold, const vector<double>& sPrice);
//Define the funciton
int main()
{
    vector<int> itemID;
    vector<string> itemName;
    vector<int> piecesOrdered;
    vector<int> piecesInStore;
    vector<int> piecesSold;
    vector<double> manufPrice;
    vector<double> sellingPrice;

    string name;
    int index;

    int choice;
    char ch;

    ifstream infile;

    infile.open("data.txt");

    if (!infile)                                                 
    {
        cout << "Input file (data.txt) does not exit." << endl;
        return 1;
    }

    getData(infile, itemID, itemName, piecesOrdered, 
                 piecesInStore, piecesSold, manufPrice,
                 sellingPrice);

    sortData(itemID, itemName, piecesOrdered,
                 piecesInStore, manufPrice, sellingPrice);           

    cout << fixed << showpoint << setprecision(2);

    menu();

    cin >> choice;
    cin.get(ch);
    cout << endl;

    while (choice != 9)
    {
        switch (choice)
        {
        case 1: cout << "Enter the name of the item: ";
                getline(cin, name);

                index = binSearch(itemName, name);
                if (index >= 0)
                    if (piecesInStore[index] > 0)
                        cout << name << " is in store." << endl;
                    else
                        cout << name << " is currently out of stock."
                             << endl;
                else
                    cout << "Store does not carry " << name 
                         << "." << endl;
                break;
        case 2: makeSale(itemName, piecesInStore,
                         piecesSold, sellingPrice);
                break;
        case 3: cout << "Enter the name of the item: ";
                getline(cin, name);

                index = binSearch(itemName, name);
                if (index >= 0)
                    cout << "The price of " << name << " = "
                         << sellingPrice[index] << "." << endl;
                else
                    cout << "Store does not carry " << name 
                         << "." << endl;
                break;
        case 4: printReport(itemID, itemName, piecesOrdered,
                            piecesInStore, piecesSold, manufPrice, 
                            sellingPrice);
                break;
        default: cout << "Invalid choice." << endl;
        }

        menu();

        cin >> choice;
        cin.get(ch);
        cout << endl;
    }


    return 0;
}

void sortData(vector<int>& iID, vector<string>& iName, 
             vector<int>& pOrdered, vector<int>& pInStore,
             vector<double>& manufPrice, 
             vector<double>& sPrice)
{
    int index;
    int smallestIndex;
    int minIndex;
    string temp;

    int temp1;
    double temp2;

    int length = static_cast<int>(iName.size());

    for (index = 0; index < length - 1; index++)
    {
        smallestIndex = index; 
        for (minIndex = index + 1; minIndex < length; minIndex++)
            if (iName[minIndex] < iName[smallestIndex])
                smallestIndex = minIndex; 

        temp1 = iID[smallestIndex];
        iID[smallestIndex] = iID[index];
        iID[index] = temp1;

        iName[smallestIndex].swap(iName[index]);

        temp1 = pOrdered[smallestIndex];
        pOrdered[smallestIndex] = pOrdered[index];
        pOrdered[index] = temp1;

        temp1 = pInStore[smallestIndex];
        pInStore[smallestIndex] = pInStore[index];
        pInStore[index] = temp1;

        temp2 = manufPrice[smallestIndex];
        manufPrice[smallestIndex] = manufPrice[index];
        manufPrice[index] = temp2;

        temp2 = sPrice[smallestIndex];
        sPrice[smallestIndex] = sPrice[index];
sPrice[index] = temp2;
    }}

int binSearch(vector<string> list, string searchItem)
{
    int first = 0;
    int last = static_cast<int>(list.size()) - 1;
    int mid;

    bool found = false;

    while (first <= last && !found)
    {
        mid = (first + last) / 2;

        if (list[mid] == searchItem)
            found = true;
        else
            if (list[mid] > searchItem)
               last = mid - 1;
            else
               first = mid + 1;
    }

    if (found) 
        return mid;
    else
        return -1;
}//end binarySearch

Edited 3 Years Ago by mike_2000_17: Fixed formatting

plus, you would think that since this a C++ forum, that it would be in C++??

plus, you would think that since this a C++ forum, that it would be in C++??

Yes, you would think so? What's your point?

This article has been dead for over six months. Start a new discussion instead.