Question: C++ issues need help ASAP!!!! So I am trying to figure out how to call line 41 to function on line 105 after you make
C++ issues need help ASAP!!!!
So I am trying to figure out how to call line 41 to function on line 105 after you make your selection it should display Selection: name, price per unit: $price
I need to know how to do this so each time you select it to display this so, for example, hit 1 for water Selection: Water, price per unit: $1.45 then it should ask for quantity. i should ask display this each choice you make until you end the loop for the summary.
This shoud look like:

Vs:

Also my Order summary is not working properly it displays nothing instead of all the choices and totals.
Should look like:

vs.

Please help me ASAP!!!!
[code]
#include
#include
#include
#include // stringstream
#include // isalph, isdigit
class Customer {
const std::string custName, custAddress;
public:
void custInfo(std::ostream &) const
{
}
void custWelcome(std::ostream &) const
{
std::cout
}
std::string custValue() const
{
return custName;
}
Customer(const std::string &inputCustName, const std::string &inputCustAddress)
: custName(inputCustName), custAddress(inputCustAddress)
{
}
};
struct Beverage {
const std::string name;
double price;
void bevInfo(std::ostream &) const
{
std::cout
}
void bevSelect(std::ostream &) const
{
std::cout
}
Beverage(const std::string &bevName, double bevPrice)
: name(bevName), price(bevPrice)
{
}
};
const int AVAILABLE_PRODUCTS_COUNT = 3;
const Beverage AVAILABLE_PRODUCTS[AVAILABLE_PRODUCTS_COUNT] = {
Beverage("Water", 1.45), // Element 0
Beverage("Soda", 2.98), // Element 1
Beverage("Ice Tea", 3.29) // Element 2
};
typedef int Quantities[AVAILABLE_PRODUCTS_COUNT];
Quantities ordered = { 0 };
double totalCost(Quantities);
void orderSummary(Quantities);
char getCharFromUser(const std::string &prompt);
Customer getCustomerFromUser();
void displayMenu(const Customer &);
void loadProductQuantity(const Beverage &, Quantities);
void doneShowOrder(const Customer &, Quantities);
double totalCost(Quantities beverageCount)//Cost loop
{
double totalCost = 0;
for (int i = 0; i
totalCost += (beverageCount[i] * AVAILABLE_PRODUCTS[i].price);
}
return totalCost;
}
void loadProductQuantity(int beverageNumber, int quantity)
{
ordered[beverageNumber] = quantity;
}
void doneShowOrder(const Customer &, Quantities)
{
orderSummary(ordered);
}
void displayMenu(const Customer &prompt)
{
std::cout
std::cout
std::cout
std::cout
std::cout
std::cout
std::cout
}
char getCharFromUser(const std::string &prompt)
{
char key;
std::cout
std::cin >> key;
return key;
}
Customer getCustomerFromUser()
{
std::string custName;
std::string custAddress;
std::cout ";
std::getline(std::cin, custName);
std::cout ";
std::getline(std::cin, custAddress);
return Customer(custName, custAddress);
}
int main(void) {
Customer patron = getCustomerFromUser();
patron.custWelcome(std::cout);
patron.custInfo(std::cout);
bool done = false;
while (!done) {
int amountOrdered = 0;
displayMenu(patron);
switch (getCharFromUser("Your selection: ")) {
case '1':
std::cout
std::cin >> amountOrdered;
loadProductQuantity(0, amountOrdered);
break;
case '2':
std::cout
std::cin >> amountOrdered;
loadProductQuantity(1, amountOrdered);
break;
case '3':
std::cout
std::cin >> amountOrdered;
loadProductQuantity(2, amountOrdered);
break;
case 'X': case 'x':
done = true;
break;
default:
std::cout
std::cin.get();
// no break in the default case
}
}
doneShowOrder(patron, ordered);
std::cout
char blah;
std::cin >> blah;
return 0;
}
void orderSummary(Quantities ordered) {
std::cout
std::cout
std::cout
for (int i = 0; i
// only show beverages that has at least one order
if (ordered[i] > 0) {
std::cout
}
}
}
[/code]
CS5115 P3 Quick Launch (Ctrl-O) n (Running) Microsoft Visual Studio File Edit View Project Build Debug Team Tools Test Analyze Window Help Joe Hotman JH S115 IP3_JosephHoffman.exe - ? Application Insights CAUsersACE istsourcerepostCSS 1 1 5-IP3JosephHo Please enter your address -=> 151 Marie Lane Hello Joseph Proc tic Tools dress: 151 Marie Lane stics session: 16 seconds 10s Joseph, Please select the beverage you would like to purchase from the menu: Drink Menu 1Water $1.45 12 Soda $2.98 13 Iced Tea $3.29 1% of all processors) x - Exit 100 Your selection: 2 Selection: Soda, price per unit : 2.98 Enter quantity [1-100]: ary Events Memory Usage CPU Usage ow Events (0 of 0 ry Usage ke Snapshot 100 % Autos Narme dows Syskow54\kernel32.dll'. Cannot fi dows\SysW016KernelBase.dll.. Cannot ndows\SyshOW 41msvcp14ad.dll'. Cannot f CSS115_IP3_JosephHoffman.exe (Win32): Loaded 'C:\WindowsSysho64vcruntime14ed.dll'. Cann CSS115_IP3_JosephHoffman.exe' (Win32): Loaded 'C:Windows SyshOW64ucrtbased.dll'. Cannot f .exe (Win32): Autos Locals Watch 1 Call Stack Breakpoints Exception Settings Command Window Immediate Window Output Ln 1 Col 1 Ch 1 INS Add to Source Control dv) ENG 10:49 PM ^
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
