Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A) Write a program to perform grocery check-out procedure for a simple store. Us

ID: 3531911 • Letter: A

Question

A)   Write a program to perform grocery check-out procedure for a simple store. Use a dynamic array of structures (Up to 100) to store this information. For each product we store the following information:

            - PLU code: Price Look Up Code. Unique for each product

            - Product Name,

            - Product Sales Type: 0 = per unit, 1 = per pound

            - Price Per Pound or Price Per Unit,

            - Current Inventory Level.

           

For example:

            4011 BANANAS 1 0.49 123.2

            4383 MINNEOLAS 1 0.79 187.3

            3144 TANGERINES 1 1.19 135.5

            4028 STRAWBERRIES_PINT 0 0.99 104

            4252 STRAWBERRIES_HALF_CASE 0 3.99 53

            4249 STRAWBERRIES_FULL_CASE 0 7.49 67

B)   Your program should:

               i.         On initialization, read inventory from products.txt (also on eLearning).

              ii.         Do check-out functionality in a separate method/function.

            iii.         Enable the user to purchase several products in each checkout.

            iv.         After the user enters PLU code, ask the user to input the weight or # of units for each product (depending on its sales type) & keep up with the total ($).

              v.         User can enter 0 for PLU code to indicate the end of checkout.

            vi.         If the total purchase exceeds $50, apply 5% discount to the total.

           vii.         A list of items and their prices should be displayed along with the total due before and after discount

         viii.         You should perform input validation (i.e. PLU should be integer, no symbols or letters are valid as PLU, unit price, sales type or stock).

You need to keep track of inventories automatically as well. So, keep updating the inventory data along with checkout operations. When the store closes every day, inventory product information should be displayed and updated in the file inventory.txt.

Thus you will have two menu items: check out, and exit.

Define a constant SIZE to store the maximum number of products

Declare a global variable to be used as dynamic array

Define a structure named Product to store product information

To read the file, call a function with the following prototype and description:

bool readInventory(string filename):

This function receives a string with the filename and location of products.txt. It should open the file, and return false if any errors occur. Once the file is open, a dynamic array of Products is created to store up to 100 elements, and then it reads the file content line by line, and validates the input. If for a given product, the information is incorrect (i.e. PLU is not an integer), skip the product and continue with the next line. Return true if no error was found and the file was read successfully

double checkout()

This function is called for every customer. It continues asking for the PLU, units/pounds (see part B) until 0 is entered as PLU, and returns the total amount ($) for the current sale.

bool upDateInventory(string filename)

This function updates the inventory before terminating the program. The file name and location should be the same as for readInventory. Returns true if the inventory file was successfully updated.


Specific Text File to be used includes:


Explanation / Answer

product.cpp





//product.h

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote