The program has defined a structure named Sale. The structure has the following fields: string itemName Milk 1 int quantity 5.85 double unitPrice Whole Wheat Bread The main function calls...


Unless specifically instructed, do not prompt the user for input during the execution of your program. Do not pause at the end of the execution waiting for the user's input.


The first one is the required template


The second one is the description


Thank you so much!


The program has defined a structure named Sale.<br>The structure has the following fields:<br>string itemName<br>Milk<br>1<br>int quantity<br>5.85<br>double unitPrice<br>Whole Wheat Bread<br>The main function calls loadUserlnput which returns a pointer to the first Sale element in the dynamically allocated<br>3.75<br>array of Sale elements and an integer for the number of Sale elements in the array.<br>Napkin<br>3<br>The main function then calls printData to show the sale items including the total of each sale item and the total of the<br>2.35<br>entire list.<br>Раper Towel<br>Function printData<br>3<br>2.95<br>This is the function you need to complete as well as two other helper functions.<br>Soap<br>In the function body, print the report heading.<br>1<br>1.95<br>Then iterate through the array received through the parameters and print the data according to the required format. For<br>the total of each item, call getltemTotal.<br>The output should look exactly as follows:<br>At the end of the report, print the total of the entire sale items by calling getTotal.<br>Test The Program<br>Sales<br>Use the following input data:<br>Item<br>Qty<br>Unit<br>Amt<br>Milk<br>1<br>5.85<br>5.85<br>Whole Wheat Bread<br>2<br>3.75<br>7.50<br>Napkin<br>Раper Towel<br>Soap<br>3<br>2.35<br>7.05<br>3<br>2.95<br>8.85<br>1<br>1.95<br>1.95<br>Total<br>31.20<br>II<br>II<br>II<br>II<br>II<br>

Extracted text: The program has defined a structure named Sale. The structure has the following fields: string itemName Milk 1 int quantity 5.85 double unitPrice Whole Wheat Bread The main function calls loadUserlnput which returns a pointer to the first Sale element in the dynamically allocated 3.75 array of Sale elements and an integer for the number of Sale elements in the array. Napkin 3 The main function then calls printData to show the sale items including the total of each sale item and the total of the 2.35 entire list. Раper Towel Function printData 3 2.95 This is the function you need to complete as well as two other helper functions. Soap In the function body, print the report heading. 1 1.95 Then iterate through the array received through the parameters and print the data according to the required format. For the total of each item, call getltemTotal. The output should look exactly as follows: At the end of the report, print the total of the entire sale items by calling getTotal. Test The Program Sales Use the following input data: Item Qty Unit Amt Milk 1 5.85 5.85 Whole Wheat Bread 2 3.75 7.50 Napkin Раper Towel Soap 3 2.35 7.05 3 2.95 8.85 1 1.95 1.95 Total 31.20 II II II II II
#include <iostream><br>#include <iomanip><br>#include <string><br>int userItems {0};<br>cin >> userItems;<br>//cout << > // that left the newline in the buffer. cin.ignore(); getline(cin, tptr->itemName); cin >> tptr ->quantity; cin >> tptr ->unitPrice; ++tptr; } *items = userItems; return ptr; 大*大大大★大*大★大**: k*大大★★大大★★★* ******** ptr; // name of sale item // quantity of item } Sale *getUserInput(int *items); double getItemTotal(const Sale *sale); double getTotal(const Sale *salePtr, int items); void printData(const Sale *salePtr, int items); int main() { int items {0}; Sale* users = getUserInput(&items); printData(users, items); delete [] users; } :********* //**** **** ***** ***** **** ******** //* getItemTotal // * // * //* Parameters: //* This function returns the total price of one sale item. return 0; } salePtr - pointer to one sale item //****** · ****: /* //* getUserInput - This function gets a list of Sale item from the user. This functions dynamically allocates an array and returns a pointer to the allocated array. The caller is responsible for deleting the allocated array. //* Return: // * //* The total price of the item. // * *** **** * double getItemTotal(const Sale *sale) { // Write your code here Parameters: items pointer to the callers variable for item counts. /* Return: } The pointer to the first Sale item in the allocated array of Sale items. // ** //* getTotal - This function returns the total price of the sale items. //* ** **** * Sale *getUserInput (int *items) { //* Parameters: /* /* salePtr items pointer to the first sale item number of sale items Return: The total price of the items. **** ****** double getTotal(const Sale *salePtr, int items) { // Write your code here } //******: **** **** ***** * ***: **** *** //* printData //* //* Parameters: This function prints a report of the sale items. // * // * //* salePtr - pointer to the first sale item items - number of sale items "/>
Extracted text: #include #include #include int userItems {0}; cin >> userItems; //cout < "useritems="" "="">< useritems="">< endl;="" sale="" *ptr="" *="" return:="" void="" *="" using="" namespace="" std;="" new="" sale[useritems]="" {};="" *="" ***="" void="" printdata(const="" sale="" *saleptr,="" int="" items)="" {="" write="" your="" code="" here="" ...="" define="" a="" data="" structure="" named="" sale.="" the="" structure="" has="" the="" following="" fields:="" struct="" sale="" {="" string="" itemname;="" int="" quantity;="" double="" unitprice;="" unit="" price="" of="" item="" };="" sale="" *tptr="" while="" (tptr="">< ptr="" +="" useritems)="" {="" this="" is="" necessary="" because="" the="" previous="" operation="" is="" a="">> // that left the newline in the buffer. cin.ignore(); getline(cin, tptr->itemName); cin >> tptr ->quantity; cin >> tptr ->unitPrice; ++tptr; } *items = userItems; return ptr; 大*大大大★大*大★大**: k*大大★★大大★★★* ******** ptr; // name of sale item // quantity of item } Sale *getUserInput(int *items); double getItemTotal(const Sale *sale); double getTotal(const Sale *salePtr, int items); void printData(const Sale *salePtr, int items); int main() { int items {0}; Sale* users = getUserInput(&items); printData(users, items); delete [] users; } :********* //**** **** ***** ***** **** ******** //* getItemTotal // * // * //* Parameters: //* This function returns the total price of one sale item. return 0; } salePtr - pointer to one sale item //****** · ****: /* //* getUserInput - This function gets a list of Sale item from the user. This functions dynamically allocates an array and returns a pointer to the allocated array. The caller is responsible for deleting the allocated array. //* Return: // * //* The total price of the item. // * *** **** * double getItemTotal(const Sale *sale) { // Write your code here Parameters: items pointer to the callers variable for item counts. /* Return: } The pointer to the first Sale item in the allocated array of Sale items. // ** //* getTotal - This function returns the total price of the sale items. //* ** **** * Sale *getUserInput (int *items) { //* Parameters: /* /* salePtr items pointer to the first sale item number of sale items Return: The total price of the items. **** ****** double getTotal(const Sale *salePtr, int items) { // Write your code here } //******: **** **** ***** * ***: **** *** //* printData //* //* Parameters: This function prints a report of the sale items. // * // * //* salePtr - pointer to the first sale item items - number of sale items
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here