Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++, create a class called GroceryList. Create three string variables ( productName, upc_code, and brand_name) and one double variable (price). Make sure to create

In C++, create a class called GroceryList.

Create three string variables ( productName, upc_code, and brand_name) and one double variable (price). Make sure to create a constructor with one 0, 1, 2, 3, or 4 arguments, with the first argument being the product name, second the brand name, third the upc, and last the price. Initialize the variables with member initialization and in the construction initialization list as well. Set and retrieve each of the attributes.

Overload the insertion and extraction operators. For example,

GroceryList groceryItem;

std::cin >> groceryItem;

std::cout << groceryItem;

The first field should be upc, then the brand, then the name, and fourth the price.

For example: "00013000001038", "Heinz", "Heinz Tomato Ketchup - 2 Ct", 21.80. (Incomplete items with errors should be ignored.) Don't try to remove or add quotes, instead use std::quoted.

Overload the 6 relational operators. For example, main() may compare GroceryList objects like:

GroceryLIst captainCrunch, cereal;

if (captainCrunch = cereal) ...

if (captainCrunch < cereal)...

Items A and B are equal if all attributes are equal (or within 0.0001 for floating point numbers). Grocery Items are to be sorted by UPC, brand name, product name, then price. For example, if As and Bs UPC are equal but As brand name is less than Bs brand name, then A is less than B.

In function main()

  1. Read a grocery item from standard input (std::cin) until end of file (create a text file with your input and then simply redirect input from that text file (see below). You know you have an incorrect solution if you have included or call the ifstream::open function.).

  2. Read a grocery item from standard input (std::cin) until end of file7. For each item read:

    i. Store the grocery item in a dynamically allocated object. ii. Store the pointer to the grocery item in a standard vector,

  3. After you have reached the end of file, write the grocery items to standard output (std::cout) in reverse order.

  4. Be sure to release the dynamically allocated objects before exiting the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

ISBN: 0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Types of Interpersonal Relationships?

Answered: 1 week ago

Question

Self-Disclosure and Interpersonal Relationships?

Answered: 1 week ago