This looks very much like some code which I suggested a couple of days ago.
I kind of assumed it wasn't suitable. Since you decided to try it, then you need to fill in some missing pieces.
I suspect the intention behind the code I began wasn't fully grasped - which is unfortunate since time is so short now.
My version of the logic function looked like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
double Logic(ostringstream & receipt)
{
char Another = 'y';
int Number = 0;
int Amount = 0;
double Total = 0;
while (Another == 'y')
{
cout << endl;
cout << "What would you like to order?: ";
cin >> Number;
cout << "Please enter the amount of the item you intend to purchase: ";
cin >> Amount;
cout << "Do you want to order another item (y/n)? ";
cin >> Another;
double cost = Amount * menu[Number].price;
Total = Total + cost;
receipt << Amount << " " << setw(15) << menu[Number].name << " $" << cost << '\n';
}
return Total;
}
|
It works very much in partnership with the vector which was created in the loadmenu function. The stringstream is an added idea I had - but I fear it may add confusion. It was a way of generating some of the text of the receipt right there, but the receipt itself won't be printed until later.
In main() you'd call it like this:
1 2 3 4 5 6 7
|
Welcome_Message() ;
LoadMenu();
Menu();
ostringstream receipt;
double Total = Logic(receipt);
Receipt(Total, receipt);
|
The logic function returns the total so far. Then the receipt function can use the value to calculate the tip and the final total.
I hope this is of some use but I'm concerned that it may be already past the deadline. If there are questions, please ask.