I/ Progran name: Labza I Description: rite the program description here.> 1 what's on your mind about this lab? write what you've learned here.> II Author: erite your name here.> / Date: erite the date you start writing the progran in mm/dd/yyy.> I/ IDE Used: II Template Date: 04/06/2021 **** winc lude winc lude winc lude

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
cin > tptr->uniterie
// Progran name: Lab2a
I/ Description: write the program description here.>
I/ What's on your mind about this lab? <write what you've learned here.>
// Author: <write your name here.>
//
/ Date: <write the date you start writing the program in mm/dd/yyyy.>
I/ IDE Used: cirite the IDE you use here.>
// Template Date: 04/06/2021
winc Lude <iostream>
winc lude <iomanip>
winc Lude <string>
using namespace std;
I/ Define a data structure named Sale.
// The structure has the following fields:
struct Sale (
string itemNane; // name of sale item
int quantity:
doub le unitprice; / unit price of iten
I/ quantity of iten
Sale "getuserInput (int 'items);
doub le getItenTotai(const Sale "sale);
doub le getTotal(const Sale 'salePtr, int itens);
void printData(const Sale "sa lePtr, int itens);
int main() (
int items (0);
Sale users getuserInput (&items);
printData(users, items);
de lete [] users;
return 0;
/I" getuserInput
This functions dynamically allocates an array and returns a pointer
to the allocated array. The caller is responsible for deleting
the allocated array.
This function gets a list of Sale item from the user.
/ Parameters:
items - pointer to the callers variable for item counts.
//' Return:
The pointer to the first Sa le item in the allocated array of Sale
itens.
Sale "getuserInput (int items) {
int useritens ();
cin > userItems;
/ cout ce "userItems " c userItems ce endl;
Sale "ptr = new Sale[userItens) ();
Sale tptr = ptr;
while (tptr < ptr • userItems) {
/ This is necessary because the previous operation is a >>
/ that lefrt the newline in the burrer.
cin, ignore();
get line(cin, tptr->itemName);
cin >
*tptr;
items = userItems;
return ptr;
//" getItemTotal - This function returns the total price of one
sale item.
* Parameters:
salePtr - pointer to one sale item
. Return:
The total price of the item.
**............
doub le getItemTotal(const Sale "sale) {
I/ write your code here ...
1/" get Total - This function returns the totaL price of the sale items.
. Parameters:
sa lePtr - pointer to the first sale item
items
number ofr sale itens
" Return:
The total price of the items.
//....................
doub le getTotal(const Sale salePtr, int items) {
I/ write your code here ..
/" printData - This function prints a report of the sale items.
" Parameters:
sa lePtr - pointer to the first salLe item
items - number of sale items
// Return:
void
void printData(const Sale salePtr, int items) {
I/ write your code here ...
Transcribed Image Text:cin > tptr->uniterie // Progran name: Lab2a I/ Description: write the program description here.> I/ What's on your mind about this lab? <write what you've learned here.> // Author: <write your name here.> // / Date: <write the date you start writing the program in mm/dd/yyyy.> I/ IDE Used: cirite the IDE you use here.> // Template Date: 04/06/2021 winc Lude <iostream> winc lude <iomanip> winc Lude <string> using namespace std; I/ Define a data structure named Sale. // The structure has the following fields: struct Sale ( string itemNane; // name of sale item int quantity: doub le unitprice; / unit price of iten I/ quantity of iten Sale "getuserInput (int 'items); doub le getItenTotai(const Sale "sale); doub le getTotal(const Sale 'salePtr, int itens); void printData(const Sale "sa lePtr, int itens); int main() ( int items (0); Sale users getuserInput (&items); printData(users, items); de lete [] users; return 0; /I" getuserInput This functions dynamically allocates an array and returns a pointer to the allocated array. The caller is responsible for deleting the allocated array. This function gets a list of Sale item from the user. / Parameters: items - pointer to the callers variable for item counts. //' Return: The pointer to the first Sa le item in the allocated array of Sale itens. Sale "getuserInput (int items) { int useritens (); cin > userItems; / cout ce "userItems " c userItems ce endl; Sale "ptr = new Sale[userItens) (); Sale tptr = ptr; while (tptr < ptr • userItems) { / This is necessary because the previous operation is a >> / that lefrt the newline in the burrer. cin, ignore(); get line(cin, tptr->itemName); cin > *tptr; items = userItems; return ptr; //" getItemTotal - This function returns the total price of one sale item. * Parameters: salePtr - pointer to one sale item . Return: The total price of the item. **............ doub le getItemTotal(const Sale "sale) { I/ write your code here ... 1/" get Total - This function returns the totaL price of the sale items. . Parameters: sa lePtr - pointer to the first sale item items number ofr sale itens " Return: The total price of the items. //.................... doub le getTotal(const Sale salePtr, int items) { I/ write your code here .. /" printData - This function prints a report of the sale items. " Parameters: sa lePtr - pointer to the first salLe item items - number of sale items // Return: void void printData(const Sale salePtr, int items) { I/ write your code here ...
. Complete the program to processes an array of structured data. Complete those portions indicated in
the template.
The program has defined a structure named Sale.
The structure has the following fields:
string itemName
int quantity
double unitPrice
The main function call loadUserlnput which returns a pointer to the first Sale element in the dynamically
allocated array of Sale elements and an integer for the number of Sale elements in the array.
The main function then calls printData to show the sale items including the total of cach sale item and
the total of the entire list.
Function printData
This is the function you need to complete as well as two other helper functions.
In the function body, print the report heading.
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.
At the end of the report, print the total of the entire sale items by calling getTotal.
Test The Program
Use the following input data:
Milk
5.85
Whole Wheet Bread
3.75
Kapkin
2.35
Paper Towel
3
2.95
Soop
1
1.95
The output should look exactly as follows:
Sales
Iten
Qty
Unit
Ant
wilk
5.85
5.85
Whole Whect Bread
Napkin
Paper Towel
Soop
3.75
2.35
2,95
7.50
3.
7.05
8.85
1.95
1.95
Total
31.20
Transcribed Image Text:. Complete the program to processes an array of structured data. Complete those portions indicated in the template. The program has defined a structure named Sale. The structure has the following fields: string itemName int quantity double unitPrice The main function call loadUserlnput which returns a pointer to the first Sale element in the dynamically allocated array of Sale elements and an integer for the number of Sale elements in the array. The main function then calls printData to show the sale items including the total of cach sale item and the total of the entire list. Function printData This is the function you need to complete as well as two other helper functions. In the function body, print the report heading. 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. At the end of the report, print the total of the entire sale items by calling getTotal. Test The Program Use the following input data: Milk 5.85 Whole Wheet Bread 3.75 Kapkin 2.35 Paper Towel 3 2.95 Soop 1 1.95 The output should look exactly as follows: Sales Iten Qty Unit Ant wilk 5.85 5.85 Whole Whect Bread Napkin Paper Towel Soop 3.75 2.35 2,95 7.50 3. 7.05 8.85 1.95 1.95 Total 31.20
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education