I need to make a program which uses 3 parallel numeric arrays, references each other, then displays the price and quantity of the supplied product id.
It gives me an error message on line 36 about my != searchforID, can anyone enlighten me as to why?
//Ch11AppE12.cpp
//Displays the price and quantity corresponding
//to the item ID entered by the user
//Created/revised by Greg Schader on 7/13/2009
#include <iostream>
#include <string>
#include <algorithm>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::transform;
int main()
{
//declare arrays
string searchforID = "";
int ids[5] = {10, 14, 34, 45, 78};
int prices[5] = {125, 600, 250, 350, 225};
int quantities[5] = {5, 3, 9, 10, 2};
//Enter product ID
cout << "Enter product ID (X to exit): ";
getline(cin, searchforID);
transform (searchforID.begin(), searchforID.end(),
searchforID.begin(), toupper);
while (searchforID != "X")
{
//Find product ID
int x = 0;
while (x < 5 && ids[x] != searchforID)
x = x + 1;
//If product ID is valid, display price and quantity
// otherwise, display error message
if (x<5)
cout << "Price for product ID " << ids[x] << ": $" << prices[x] << " and quantity is: " << quantities[x] << endl << endl;
else
cout << "Invalid product ID" << endl << endl;
//end if function
//Enter product ID
cout << "Enter product ID (X to exit): ";
getline(cin, searchforID);
transform (searchforID.begin(), searchforID.end(),
searchforID.begin(), toupper);
} //End of while function
return 0;
} //end of main function