Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this part, you will write a class that manages a shopping list called shoppingList.cpp that runs on ShoppingListManager.epp (the main program). A shopping list
In this part, you will write a class that manages a shopping list called shoppingList.cpp that runs on ShoppingListManager.epp (the main program). A shopping list is simply a list of items and prices, here is an overview of our member functions in shoppingList.h: #include #include using namespace std; class ShoppingList private: string file_name; fstream myFile; string most_expensive_item; string name; double price; double max_price; public: ShoppingList ( ) ; bool fileOpen (istreams in) ; bool itemExists (istream& in) ; void addItem(istream& in) ; void printMostExpensiveItem( ) ; void printAll(); void printTranspose ( ); void priceSort () ; You may have different member variables and constructors, but you must include the member functions shown above. You can decide the return type as long as it works. Also, this is the sample input file(itemCatalog. txt):P1 (15 points) * Write a member function called bool item Exists(istream in) in your ShoppingList.cpp class. This function checks if the user input item exists in the input txt. If it exists, display its price. Sample Output: Please select an option: i Enter the item name: EosR5 The item exists and it costs $3899 (a) - add an item and its price (e) - print the most expensive item in the list (i) - check to see if this item exists (p) - print all items and its price (q) - quit the program (s) - print in price decending order (t) - print transposed form Please select an option: i Enter the item name: ps4 The item does not exist P.S. You may want to use one of the following functions after myFile.eof(): myFile. seekg (0, los : : end); //this moves the cursor to the end of the file. myFile. seekg(0, ios::beg); //this moves the cursor to the start of the file. P.P.S. By finishing task 1, you already open the file, so you don't need to open it again in this or other task; you don't need to close it either, because you can't read a closed file. * Write a member function called void addItem() in your ShoppingList.epp class, and verify its functionality by using functions you created from previous task.Sample Output: Please select an option: a Enter item name and its price: Xbox 499 (a) - add an item and its price (e) - print the most expensive item in the list (i) - check to see if this item exists (p) - print all items and its price (q) - quit the program (s) - print in price decending order (t) - print transposed form Please select an option: p 1. RTX_3080 $699 2. Play_Station $499 3. "Heidi" $14.99 4. ipad_Pro $999 5. Kindle_Oasis $199.99 6. EosR5 $3899 7. Xbox $499 * Write a member function called void printMostExpensiveItem() in your ShoppingList. cpp class. Sample Output: (a) - add an item and its price (e) - print the most expensive item in the list (1) - check to see if this item exists (p) - print all items and its price (q) - quit the program (s) - print in price decending order (t) - print transposed form Please select an option: e The most expensive item is EosRS and it costs $3899
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