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 that is said in the description Please use the template Thank you!

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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 that is said in the description

Please use the template Thank you!

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
Transcribed Image 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>
#include <iomanip>
#include <string>
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
Transcribed Image Text:#include <iostream> #include <iomanip> #include <string> 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
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY