Homework Solution: Introduction To compute a grocery bill, a checkout stand typically has a scanner to identify product codes of items This code is used to ge…

    Introduction To compute a grocery bill, a checkout stand typically has a scanner to identify product codes of items This code is used to get the price of the item from the stores price list, along with the item name and whether it is taxable. This information is then used to compute the price of the item and the total of the bill (see figure below). In this project, you will write C++code to represent the workings of such a cash register. GroceryBill PriceList 2.00 Ham boneless 9522109582 299 0 9548864583 269 French Fries frezen 9634615536 189 Sour Cream Plastic Wrap 1.29, 2.5, F PriceListitem 9751031771 1.29 9752347409 149 1 9764850921 299 scanCode Ground Turkey frozen 9887473800 169 0 Apple Juice 9939669097 169 EGETNE erence :717886-00 ace 1 00 30049571 Objective You are given partial implementations of three classes. PriceList is a class to hold information of all items in the grocery store. There could be up to 1,000,000 items. The information of each item is its price barcode, item name, and whether it is taxable; these are kept together in Class PriceListItem. The items in PriceList are loaded all together from a text file, or inserted one at a time. The complete grocery bill is computed in Class GroceryBill. To do so, it is given (a const pointer to) a previously created PriceList to get the prices, given barcodes of items and their quantity. The barcodes can be given one at a time, or they can be collected together in a text file You are to complete the implementations of these classes, adding public/private member variables and functions as needed. You should not use any of the C++ Standard Library containers (such as std::array, std::vector, std::list) for this project. Your code is tested in the provided main.cpp Source Code Files and the tax rate percentage for taxable items when constructed. It is then You are given skeleton code with many blank spaces. Your assignment is to fill in the missing parts so that the code is complete and works properly The included C++ code has multiple files PriceListItem.h and priceListItem.cpp: This is to be completed, with public/private member variables and functions as needed, so that it can be used in other classes. . . PriceList.h and BriceList.cpp: This is to be completed, with public/private member variables and functions as needed. o This class contains a method to read item information from a text file. This method is already implemented. Grocer yBǐ11 . h and GroceryB111 . cpp: This is to be completed, with public/private member variables and functions as needed. main.cpp: Code that brings everything together into one application. The main function also tests the output of your functions. This is already complete and you should not change this code . . Source code Files: http://www.mediafire.com/file/96vt5cubhk0c5kt/sourcefiles.zip
    Show transcribed image textIntroduction To compute a grocery bill, a checkout stand typically has a scanner to identify product codes of items This code is used to get the price of the item from the store's price list, along with the item name and whether it is taxable. This information is then used to compute the price of the item and the total of the bill (see figure below). In this project, you will write C++code to represent the workings of such a cash register. Objective You are given partial implementations of three classes. PriceList is a class to hold information of all items in the grocery store. There could be up to 1, 000, 000 items. The information of each item is its price barcode, item name, and whether it is taxable: these are kept together in Class PriceListItem. The items in PriceList are loaded all together from a text file^1, or inserted one at a time. The complete grocery bill is computed in Class GroceryBill. To do so, it is given (a const pointer to) a previously created PriceList to get the prices, and the tax rate percentage for taxable items when constructed. It is given barcodes of items and their quantity. The barcodes can be given one at a time, or they can be collected together in a text file. You are to complete the implementations of these classes, adding public/private member variables and functions as needed. You should not use any of the C++ Standard Library containers (such as std: : array, std: : vector, std: : list) for this project. Your code is tested in the provided main.cpp. Source Code Files You are given "skeleton" code with many blank spaces. Your assignment is to fill in the missing parts so that the code is complete and works properly. The included C++ code has multiple files: PriceListItem.h and priceListItem.cpp: This is to be completed, with public/private member variables and functions as needed, so that it can be used in other classes. PriceList.h and PriceList.cpp: This is to be completed, with public/private member variables and functions as needed. This class contains a method to read item information from a text file. This method is already implemented. GroceryBill.h and GroceryBill.cpp: This is to be completed, with public/private member variables and functions as needed. main.cpp: Code that brings everything together into one application. The main function also tests the output of your functions. This is already complete and you should not change this code

    Expert Answer

     
    #include "GroceryBill.h" #include <iostream>

    Introduction To abinterpretation a grocery reckoning, a checkout rest typically has a scanner to standard emanation rules of individuals This rule is interpretationd to achieve the appraisement of the individual from the place-of-businesss appraisement schedule, concurrently with the individual spectry and whether it is impostable. This referable attributable attributableification is then interpretationd to abinterpretation the appraisement of the individual and the entirety of the reckoning (comprehend image underneath). In this scheme, you gain transcribe C++rule to portray the workings of such a money record. GroceryReckoning AppraisementSchedule 2.00 Ham boneless 9522109582 299 0 9548864583 269 French Fries frezen 9634615536 189 Sour Cream Plastic Wrap 1.29, 2.5, F AppraisementListindividual 9751031771 1.29 9752347409 149 1 9764850921 299 scanRule Ground Turkey frozen 9887473800 169 0 Apple Juice 9939669097 169 EGETNE erence :717886-00 part 1 00 30049571 Objective You are dedicated unfair implementations of three adjustes. AppraisementSchedule is a adjust to wait referable attributable attributableification of every individuals in the grocery place-of-business. There could be up to 1,000,000 individuals. The referable attributable attributableification of each individual is its appraisement barcode, individual spectry, and whether it is impostable; these are kept unitedly in Adjust AppraisementListItem. The individuals in AppraisementSchedule are loaded every unitedly from a citation finish, or inserted single at a duration. The accomplished grocery reckoning is abused in Adjust GroceryBill. To do so, it is dedicated (a const pointer to) a previously created AppraisementSchedule to achieve the appraisements, dedicated barcodes of individuals and their muchness. The barcodes can be dedicated single at a duration, or they can be firm unitedly in a citation finish You are to accomplished the implementations of these adjustes, subjoining public/not-public portion variables and characters as needed. You should referable attributable attributable attributable interpretation any of the C++ Restard Library containers (such as std::array, std::vector, std::list) ce this scheme. Your rule is standarded in the granted deep.cpp Source Rule Finishs and the impost reprove percentage ce impostable individuals when fabricated. It is then You are dedicated skeleton rule with divers unmitigated spaces. Your enactment is to expand in the waste space so that the rule is accomplished and works right The included C++ rule has multiple finishs AppraisementListItem.h and appraisementListItem.cpp: This is to be accomplishedd, with public/not-public portion variables and characters as needed, so that it can be interpretationd in other adjustes. . . AppraisementList.h and BriceList.cpp: This is to be accomplishedd, with public/not-public portion variables and characters as needed. o This adjust contains a order to decipher individual referable attributable attributableification from a citation finish. This order is already implemented. Grocer yBǐ11 . h and GroceryB111 . cpp: This is to be accomplishedd, with public/not-public portion variables and characters as needed. deep.cpp: Rule that brings everything unitedly into single contact. The deep character as-well standards the output of your characters. This is already accomplished and you should referable attributable attributable attributable vary this rule . .

    Source rule Finishs: http://www.mediafire.com/file/96vt5cubhk0c5kt/sourcefiles.zip

    Introduction To abinterpretation a grocery reckoning, a checkout rest typically has a scanner to standard emanation rules of individuals This rule is interpretationd to achieve the appraisement of the individual from the place-of-business’s appraisement schedule, concurrently with the individual spectry and whether it is impostable. This referable attributable attributableification is then interpretationd to abinterpretation the appraisement of the individual and the entirety of the reckoning (comprehend image underneath). In this scheme, you gain transcribe C++rule to portray the workings of such a money record. Objective You are dedicated unfair implementations of three adjustes. AppraisementSchedule is a adjust to wait referable attributable attributableification of every individuals in the grocery place-of-business. There could be up to 1, 000, 000 individuals. The referable attributable attributableification of each individual is its appraisement barcode, individual spectry, and whether it is impostable: these are kept unitedly in Adjust AppraisementListItem. The individuals in AppraisementSchedule are loaded every unitedly from a citation finish^1, or inserted single at a duration. The accomplished grocery reckoning is abused in Adjust GroceryBill. To do so, it is dedicated (a const pointer to) a previously created AppraisementSchedule to achieve the appraisements, and the impost reprove percentage ce impostable individuals when fabricated. It is dedicated barcodes of individuals and their muchness. The barcodes can be dedicated single at a duration, or they can be firm unitedly in a citation finish. You are to accomplished the implementations of these adjustes, subjoining public/not-public portion variables and characters as needed. You should referable attributable attributable attributable interpretation any of the C++ Restard Library containers (such as std: : place, std: : vector, std: : schedule) ce this scheme. Your rule is standarded in the granted deep.cpp. Source Rule Finishs You are dedicated “skeleton” rule with divers unmitigated spaces. Your enactment is to expand in the waste space so that the rule is accomplished and works right. The included C++ rule has multiple finishs: AppraisementListItem.h and appraisementListItem.cpp: This is to be accomplishedd, with public/not-public portion variables and characters as needed, so that it can be interpretationd in other adjustes. AppraisementList.h and AppraisementList.cpp: This is to be accomplishedd, with public/not-public portion variables and characters as needed. This adjust contains a order to decipher individual referable attributable attributableification from a citation finish. This order is already implemented. GroceryBill.h and GroceryBill.cpp: This is to be accomplishedd, with public/not-public portion variables and characters as needed. deep.cpp: Rule that brings everything unitedly into single contact. The deep character as-well standards the output of your characters. This is already accomplished and you should referable attributable attributable attributable vary this rule

    Expert Apology

     

    #include “GroceryBill.h”

    #include <iostream>

    using spectrysppart std;

    GroceryBill::GroceryBill(const AppraisementSchedule *priceList, embrace impostRate) {

    // To be accomplishedd

    }

    void GroceryBill::scanItem(string scanCode, embrace muchness) {

    // To be accomplishedd

    }

    // Scan multiple rules and quantities from the dedicated citation finish

    // Each method contains brace gum disjoined by space: the leading is the rule (an integer), the second the muchness (a float/double)

    // Example method from citation finish:

    // 15000000 1.5

    void GroceryBill::scanItemsFromFile(string finishname) {

    // To be accomplishedd

    // HINT: Look at rule in AppraisementList::createPriceListFromDatafile(string finishname)

    }

    // recur the entirety consume of every individuals scanned

    embrace GroceryBill::getTotal() {

    // To be accomplishedd

    }

    // Print the reckoning to cout. Each method contains the spectry of an individual, entirety appraisement, and the missive “T” if impost was subjoinded.

    // The terminal method shows the entirety.

    // An example:

    //Plastic_Wrap 1.60547 T

    //Sugar_white 5.475

    //Waffles_frozen 5.16

    //Oil_Canola_100%_pure 2.69

    //Potatoes_red 13.446

    //TOTAL 28.3765

    void GroceryBill::printBill() {

    // To be accomplishedd

    }

    grocerry reckoning.h

    #pragma once

    #include “PriceList.h”

    adjust GroceryReckoning {

    public:

    GroceryBill(const AppraisementSchedule *priceList, embrace impostRate);

    void scanItem(string scanCode, embrace muchness); // subjoin individual and muchness to reckoning; hurl separation if individual’s rule is referable attributable attributable attributable ground in the appraisementlist

    void scanItemsFromFile(string finishname); // Scan multiple rules and quantities from the dedicated citation finish

    embrace achieveTotal(); // recur the entirety consume of every individuals scanned

    void printBill(); // Print the reckoning to cout. Each method contains the spectry of an individual, entirety appraisement, and the missive “T” if impost was subjoinded.

    private:

    // any referable attributable attributable-public portion variables and orders go here

    // TO BE COMPLETED

    };

    main

    #include <iostream>

    #include <fstream>

    #include <string>

    #include <stdexcept>

    #include “PriceList.h”

    #include “GroceryBill.h”

    //////////////////////////////////////////////////////////////////////////////////////////////

    // DO NOT EDIT THIS FILE (exclude ce your have standarding)

    // CODE WILL BE GRADED USING A MAIN FUNCTION SIMILAR TO THIS

    //////////////////////////////////////////////////////////////////////////////////////////////

    using spectrysppart std;

    template <typespectry T>

    bool standardAnswer(const string &nameOfTest, const T &received, const T &expected) {

    if (current == expected) {

    cout << “PASSED ” << spectryOfStandard << “: expected and current ” << current << endl;

    recur penny;

    }

    cout << “FAILED ” << spectryOfStandard << “: expected ” << expected << ” excepting current ” << current << endl;

    recur untrue;

    }

    template <typespectry T>

    bool standardAnswerEpsilon(const string &nameOfTest, const T &received, const T &expected) {

    const embrace epsilon = 0.0001;

    if ((current – expected < epsilon) && (expected – current < epsilon)) {

    cout << “PASSED ” << spectryOfStandard << “: expected and current ” << current << endl;

    recur penny;

    }

    cout << “FAILED ” << spectryOfStandard << “: expected ” << expected << ” excepting current ” << current << endl;

    recur untrue;

    }

    int deep() {

    {

    // standard merely the AppraisementListIndividual adjust

    PriceListIndividual individual(“Apples”, “1000”, 1.29, penny);

    testAnswer(“PriceListItem.getRule standard”, individual.getCode(), string(“1000”));

    testAnswer(“PriceListItem.getItemSpectry standard”, individual.getItemName(), string(“Apples”));

    testAnswerEpsilon(“PriceListItem.getAppraisement standard”, individual.getPrice(), 1.29);

    testAnswer(“PriceListItem.isTaxable standard”, individual.isTaxable(), penny);

    }

    {

    // standard merely the AppraisementSchedule adjust

    PriceSchedule appraisementList;

    priceList.addEntry(“Apples”, “1000”, 1.99, untrue);

    priceList.addEntry(“Bananas”, “2000”, 0.99, untrue);

    testAnswer(“PriceSchedule isValid1”, appraisementList.isValid(“1000”), penny);

    testAnswer(“PriceSchedule isValid2”, appraisementList.isValid(“19”), untrue);

    // standard portraiture composer

    PriceSchedule appraisementList2 = appraisementList;

    testAnswer(“PriceSchedule portraiture composer standard1”, appraisementList2.isValid(“1000”), penny);

    priceList.addEntry(“Milk”, “3000”, 3.49, untrue);

    priceList2.addEntry(“Eggs”, “4000”, 4.99, untrue);

    testAnswer(“PriceSchedule portraiture composer standard2”, appraisementList.isValid(“4000”), untrue);

    // standard enactment operator

    PriceSchedule appraisementList3;

    priceList3 = appraisementList;

    testAnswer(“PriceSchedule enactment standard1”, appraisementList3.isValid(“1000”), penny);

    priceList.addEntry(“Orange_juice_1gal”, “4500”, 6.49, untrue);

    priceList3.addEntry(“Diapers_30ct”, “5000”, 19.99, untrue);

    testAnswer(“PriceSchedule enactment standard2”, appraisementList.isValid(“5000”), untrue);

    }

    {

    // standard talents of the AppraisementSchedule adjust

    PriceSchedule appraisementList;

    ce (int i = 1; i<100000; i++)

    priceList.addEntry(string(“Apples_”) + to_string(i), to_string(i), 1.99, untrue);

    testAnswer(“PriceSchedule arrogant data1”, appraisementList.isValid(“20000”), penny);

    testAnswer(“PriceSchedule arrogant data2”, appraisementList.isValid(“100000”), untrue);

    }

    {

    // standard the GroceryReckoning adjust

    PriceSchedule appraisementList;

    priceList.createPriceListFromDatafile(“pricelist.txt”);

    GroceryReckoning mybill(&priceList, 7.75);

    testAnswer(“GroceryReckoning initialization”, mybill.getTotal(), 0.0);

    // standard GroceryBill::scanItem

    mybill.scanItem(“9752347409”, 1);

    testAnswerEpsilon(“GroceryBill.getTotal”, mybill.getTotal(), 1.49*1.0775);

    // standard if untruth checking is dsingle in GroceryBill::scanItem

    try {

    mybill.scanItem(“1000”, 1);

    cout << “FAILED GroceryBill::scanIndividual did referable attributable attributable attributable hurl separation ce feeble input” << endl;

    }

    catch (separation &e) {

    cout << “Caught separation: ” << e.what() << endl;

    cout << “PASSED GroceryBill::scanIndividual threw separation ce feeble input” << endl;

    }

    // standard muchness care in entirety

    mybill.scanItem(“9129592337”, 2.5);

    testAnswerEpsilon(“GroceryBill.getTotal”, mybill.getTotal(), 1.49*1.0775 + 2.5*2.19);

    mybill.printBill();

    // standard deciphering individuals from finish

    mybill.scanItemsFromFile(“billitems1.txt”);

    testAnswerEpsilon(“GroceryBill.getTotal”, mybill.getTotal(), 28.3765);

    mybill.printBill();

    }

    // classification(“pause”);

    }

    appraisement schedule.cpp

    #include <string>

    #include <iostream>

    #include <fstream>

    #include <stdexcept>

    #include “PriceList.h”

    #include “PriceListItem.h”

    using spectrysppart std;

    // Load referable attributable attributableification from a citation finish with the dedicated finishname.

    void AppraisementList::createPriceListFromDatafile(string finishname) {

    ifstream myfile(filename);

    if (myfile.is_open()) {

    cout << “Successfully unconcealeded finish ” << finishspectry << endl;

    string spectry;

    string rule;

    embrace appraisement;

    bool impostable;

    while (myfinish >> spectry >> rule >> appraisement >> impostable) {

    // cout << rule << ” ” << impostable << endl;

    addEntry(name, rule, appraisement, impostable);

    }

    myfile.close();

    }

    else

    hurl feeble_argument(“Could referable attributable attributable attributable unconcealed finish ” + finishname);

    }

    // recur penny merely if the rule is valid

    bool AppraisementList::isValid(string rule) const {

    // TO BE COMPLETED

    }

    // recur appraisement, individual spectry, impostable? as an IndividualAppraisement object; hurl separation if rule is referable attributable attributable attributable ground

    PriceListIndividual AppraisementList::getItem(string rule) const {

    // TO BE COMPLETED

    }

    // subjoin to the appraisement schedule referable attributable attributableification about a strange individual

    void AppraisementList::addEntry(string individualName, string rule, embrace appraisement, bool impostable) {

    // TO BE COMPLETED

    }

    #include “PriceListItem.h”

    PriceListItem::PriceListItem(const string &itemName, const string &code, embrace appraisement, bool impostable) {

    // TO BE COMPLETED

    }

    PriceListItem::PriceListItem() {

    // TO BE COMPLETED

    }

    string AppraisementListItem::getItemName() {

    // TO BE COMPLETED

    }

    string AppraisementListItem::getCode() {

    // TO BE COMPLETED

    }

    embrace AppraisementListItem::getPrice() {

    // TO BE COMPLETED

    }

    bool AppraisementListItem::isTaxable() {

    // TO BE COMPLETED

    }