Oct 16, 2011 at 3:28pm UTC
Help, I have been working on this program forever and cannot get it to run. I am sure I am just missing something. Can someone help me out.
Thanks so much!
#include <iostream>
#include <string>
using namespace std;
double (*search_item) (int, int, double);
const int SIZE = 6;
void display (int *valid_item, double *valid_item_price);
int main ()
{
// arrays being used
int valid_item[6] = {106, 108, 307, 405, 457, 688};
double valid_item_price[6]= {0.59, 0.99, 4.50, 15.99, 17.50, 39.00};
// variables
string name;
string address;
int item = 0;
int quantity = 0;
int total = 0;
//int price = 0;
string MSG_YES = "Item Available";
string MSG_NO = "Item not found, Sorry!!";
// get name and address
cout <<"Enter your name: ";
cin >> name;
cout << "Enter your mailing address: ";
cin >> address;
// get the item and quantity
cout << "What item are you looking for? ";
cin >> item;
cout << "How many do you want to order? ";
cin >> quantity;
// search for item and get the price
*(search_item) (int item_list, int item, double price_list);
{ //process
double price = 0;
int i = 0;
while (i < 6)
{if (item == *(item_list + i))
{price = *(price_list + i);
}
// end if
i++;
}
//end while
return price;
// calculate the total price
total= (quantity * price);
}
// results output
if (price >0)
{
cout << MSG_YES << endl;
cout << "They cost $" << price << "each."<< endl;
cout<<"The total cost is $"<<total<< endl;
}
else
cout << MSG_NO<< endl;
// end if
system ("pause");
return 0;
} // end of main function