Hi,
i am trying to write a program for my homework.
Write a function, lookupPrice that uses the product code to look up for the price. If the product code is on special promotion, a 10% discount is given. If the product code is found, the function returns the price, otherwise it returns 0.0 The function prototype is as follows:
double lookupPrice (int prodCode)
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct product
{
int pCode;
string pDesc;
double pCost;
bool sPromo;
};
double lookupPrice(int);
int main()
{
int id;
double pprice;
cout << "Please select a product code: ";
cin >> id;
pprice = lookupPrice(id);
cout << "Price is "<<pprice;
cin.ignore();
cin.ignore();
return 0;
}
double lookupPrice(int id)
{
product products[10] =
{
{1000, "Pilot Blue Pen", 1.20, "Yes"},
{1001, "Pilot Black Pen", 1.35, "No"},
{1002, "File", 1.50, "No"},
{1003, "Exercise Book", 0.90, "Yes"}
};
if (product.sPromo="Yes")// this is where the error takes place when i try to compile. 1>test4.cpp(41): error C2059: syntax error : '.' and many other error are related to the '.' in this function.
{
product.pCost=product.pCost-product.pCost/10;}
else
{product.pCost=product.pCost;
}
return (product.pCost);
}