Below is my code I need help adding the following features:
*Print the order summary, including the products, the quantities, and the total price for each product
*Calculate and print the total price for the order
I can really use help solving this. One of the requirements was to *Ask customers to select multiple products and quantities. It seems I got this figured out just need help with the last two features. Please help ASAP! real help not sending me a link to more confusion.
// Use of functions
#include <iostream>
#include <string>
using namespace std;
void displayMenu(string userName)
{
cout << userName << ", Please select the beverage you would like to purchase from the menu: " << endl;
int main(void)
{
char selection = ' ';
string name = "";
double price, subtl;
int code, quantity;
double total = 0; //allows you to use += to calculate produce subtotal since no tax.
//Will also reset total to 0 when you want to serve a new customer.
//Ask user for her/his name
cout << "Please enter your name ==> ";
getline(cin, name);
//display user name
cout << "Hello " + name << endl;
cout << "Would you like to see our drink menu: (Y/N)\n";
cin >> selection;
while (selection == 'y' || selection == 'Y')
{
displayMenu(name);
do
{
// display menu
//displayMenu(name);
cout << "Please select: ";
// read user selection
cin >> selection;
switch (selection)
{
case '1':
cout << "You selected Water" << endl;
cout << "Enter Quantity:";
cin >> quantity;
if (quantity <= 0)
{
cout << "Invalid Quantity" << endl;
cin >> quantity;
}
price = 1.45;
subtl = (quantity*price);
cout << "Subtotal $\n" << subtl << endl;
viewOption1(name);
break;
case '2':
cout << "You selected Soda" << endl;
cout << "Enter Quantity:";
cin >> quantity;
if (quantity <= 0)
{
cout << "Invalid Quantity" << endl;
cin >> quantity;
}
price = 2.98;
subtl = (quantity*price);
cout << "Subtotal $\n" << subtl << endl;
viewOption2(name);
break;
case '3':
cout << "You selected Iced Tea" << endl;
cout << "Enter Quantity:";
cin >> quantity;
if (quantity <= 0)
{
cout << "Invalid Quantity" << endl;
cin >> quantity;
}
price = 3.29;
subtl = (quantity*price);
cout << "Subtotal $\n" << subtl << endl;
viewOption3(name);
break;
cout << "Thank you!!!" << endl;
break;
case '0'://Sentinal value that gives subtotal (because no tax) then ends your function.
cout << "Subtotal: \n" << total << endl;
break;
// other than 1, 2, 3 and X...
default: cout << "Invalid selection. Please try again ";
// no break in the default case
}
total += subtl; //will add all the produce values up. is read as total=total+subt
} while (selection != 0);//checks if code = 0 at the end of function wont end till it is.
}
cout << "Would you like to continue shopping?(Y/N)";
cin >> selection;
}