Hi I'm fairly new to C++ programming and I'm having trouble trying to understand the error messages I'm receiving.
These are the errors
expected expression on the line that says "return true;" and "expected unqualified-id" before "}) void printInitialHeader( )"
Do i have to declare something? I need an idea how to solve this. Thank You
These are the errors
expected expression on the line that says "return true;" and "expected unqualified-id" before "}) void printInitialHeader( )"
Do i have to declare something? I need an idea how to solve this. Thank You
int main()
{
string bidder1Name, bidder2Name;
double bid1,bid2 ;
double reservePrice;
string lotName;
printInitialHeader();
cout << "Enter lot name:";
cin >> lotName;
cout << "Reserve price ";
cin >> reservePrice;
if(reservePrice <= 0)
{
printErrorMessage(5);
}
else
{
bidder1Name = readName("bidder1Name");
bid1 = readPrice("bid1");
isBidPriceGood(bid1, reservePrice);
bidder2Name = readName("bidder2Name");
bid2 = readPrice("bid2");
isBidPriceGood(bid2, reservePrice);
isBidPriceGood(bid1, reservePrice);
isBidPriceGood(bid2, reservePrice);
calculateWhoWins( bidder1Name, bidder2Name,lotName, bid1, bid2, reservePrice);
}
return 0;
}
string readName(string prompt)
{
string Prompt;
cout << "enter bidder ID:";
cin >> prompt;
return prompt;
}
double readPrice(string prompt)
{
double bidPrice;
string junk;
cout << prompt << endl;;
cin >> bidPrice;
getline(cin,junk);
return bidPrice;
}
bool isBidPriceGood( double bidPrice, double reservePrice )
{
if (bidPrice >= reservePrice && bidPrice > 0)
{
return true;
else if (bidPrice < 0 && bidPrice == " ")
{
printErrorMessage(2);
return false;
}
else
{
printErrorMessage(1);
return false;
}
}}
void printDetailsOfWinner(string bidderName, string lotName, double bid)
{
cout << "Congratulations, " << bidderName << endl << ", You won "<<lotName<<" at a price of $" << bid << endl;
}
void calculateWhoWins(string bidder1Name, string bidder2Name, string lotName,
double bid1, double bid2, double reservePrice)
{
if (bid1 < reservePrice && bid2 < reservePrice)
{
printErrorMessage(4);
}
else if (bid2 < reservePrice && bid1 >= reservePrice)
{
printDetailsOfWinner(bidder1Name,lotName,reservePrice);
}
else if (((bid2 >= reservePrice && bid1 >= reservePrice)) && (bid2 < bid1))
{
printDetailsOfWinner(bidder1Name,lotName,bid2);
}
else if ((bid2 >= reservePrice && bid1 >= reservePrice) && (bid2 >= bid1 && bid2 < bid1))
{
printDetailsOfWinner(bidder1Name,lotName,bid1);
}
else if ((bid2 >= reservePrice && bid1 >= reservePrice) && (bid2 > bid1))
{
printDetailsOfWinner(bidder2Name,lotName,bid1);
}
else if (bid2 > reservePrice && bid1 < reservePrice)
{
printDetailsOfWinner(bidder2Name,lotName,reservePrice);
}
})
void printInitialHeader()
{
cout << "----------------------------------------" << endl
<< " e-Vintage Breakfast Cereals " << endl
<< " Fine Cereal Sales " << endl
<< " ----------------------------------------" << endl << endl;
cout << fixed << showpoint; // sets up doubles to print
cout << setprecision(2); // with 2 decimal locations
}
)
bool isBidPriceGood(double bidPrice, double reservePrice)
{
double bidPrice;
if (bidPrice > reservePrice)
{
isBidPriceGood = true;
cout << bidder1 << "is high bidder, current price = " << reservePrice << endl;
return 0;
}
else
{
isBidPriceGood = false;
printErrorMessage(1);
}
}
void printErrorMessage(int num)
{
if (num == 1) {
cout << endl
<< " ERROR: Reserve not met, bid rejected" << endl << endl;
} else if (num == 2) {
cout << endl
<< " ERROR: Negative price, bid rejected" << endl << endl;
} else if (num == 3) {
cout << endl
<< " ERROR: Blank bidder ID, no bid allowed" << endl << endl;
} else if (num == 4) {
cout << endl
<< "ERROR: Neither bidder met Reserve, auction canceled"<< endl << endl;
} else if (num == 5) {
cout << endl
<< "ERROR: Reserve is not positive, auction canceled" << endl << endl;
} else {
cout << " This should never print" << endl << endl;
}
}