Question
I got the following Error: See on the screenshot, the input (preprogrammed input from system testing my code), then my output of my code after
I got the following Error:
See on the screenshot, the input (preprogrammed input from system testing my code), then my output of my code after testing with the preset input, then the expected output at the end. I do not understand how to fix that issue. I believe the problem lays within the main.cpp:
#include
#include
#include
#include "ShoppingCart.h"
using namespace std;
char PrintMenu()
{
char answer;
cout
cout
cout
cout
cout
cout
cout
while (true)
{
cout
cin >> answer;
if (answer == 'a' || answer == 'A')
break;
if (answer == 'd' || answer == 'D')
break;
if (answer == 'c' || answer == 'C')
break;
if (answer == 'i' || answer == 'I')
break;
if (answer == 'o' || answer == 'O')
break;
if (answer == 'q' || answer == 'Q')
break;
}
return answer;
}
ItemToPurchase AddItem()
{
string itemName = "";
string itemDescription;
int itemQuantity;
int itemPrice;
cout
cout
cin.ignore();
getline(cin, itemName);
cout
cin.ignore();
getline(cin, itemDescription);
cout
cin >> itemPrice;
cout
cin >> itemQuantity;
ItemToPurchase itemToAdd(itemName, itemDescription, itemPrice, itemQuantity);
return itemToAdd;
}
int main()
{
string itemToRemove;
string itemToModify;
string customerName;
string currentDate;
cout
getline(cin, customerName);
cout
getline(cin, currentDate);
cout
cout
ShoppingCart itemCart(customerName, currentDate);
char answer = PrintMenu();
while (answer != 'q')
{
if (answer == 'o' || answer == 'O')
{
cout
itemCart.PrintTotal();
}
if (answer == 'a' || answer == 'A')
{
itemCart.AddItem(AddItem());
}
if (answer == 'i' || answer == 'I')
{
cout
itemCart.PrintDescriptions();
}
if (answer == 'd' || answer == 'D')
{
cout
cin.ignore();
getline(cin, itemToRemove);
itemCart.RemoveItem(itemToRemove);
}
if (answer == 'c' || answer == 'C')
{
string itemName;
cout
cout
cin.ignore();
getline(cin, itemName);
itemCart.ModifyItem(itemName);
}
if (answer == 'q' || answer == 'Q')
break;
answer = PrintMenu();
}
}
Thank you!
n / rogram: online snopping cart (continued) (C++ John Doe February 1, 2016 Nike Romaleos Volt color, Weightlifting shoes 189 Chocolate Chips Semi-sweet Input3 Powerbeats 2 Headphones Bluetooth headphones 128 1 Thermos Stainless Steel King Choose an option: DD ITEM TO CART Enter the item name: Enter the item description: Enter the item price: Enter the item quantity: ENU a Add item to cart - Remove item from cart Change item quantitye -Output items' descriptions - Output shopping carte ooks E zyBooks catalog 7.21: Ch 7 Program: Online shopping cart (continued)(C++) -Quite hoose an option: ADD Enter the item name: Enter the item description: Enter the item price: Enter the item quantity: ITEM TO CART MENU Add item to cart - Remove item from cart c -Change item quantity -Output items' descriptions o-Output shopping cart Quite Your output ends with Choose an option: ADD ITEM TO CART Enter the item name: Enter the item description: Enter the item price: Enter the item quantity: MENU Add item to cart dRemoveitem from cart Change item quantity Output items' descriptionse Output - shopping cart - Quite Choose an option: CHANGE ITEM QUANTITY Enter the item name Change item quantity i Output items' descriptions -Output shopping carte - Quit Choose an option: CHANGE ITEM QUANTITY Enter the item name: Item not found in cart. Nothing modified MENU aAdd item to cart d- Remove item from cart c-Change item quantity i Output items' descriptions oOutput shopping cart g Quit Choose an option: Choose an option: CHANGE ITEM QUANTIT Enter the item name: Enter the new quantity: Item not found in cart. Nothing modified. MENU xpected output aAdd item to cart ends with d- Remove item from cart c-Change item quantity i- Output items' descriptions oOutput shopping cart Quit Choose an option
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started