Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Define Data Structures: Define a data structure named Sale. The structure has the following fields: string itemName int quantity double unitPrice double salePrice Write

C++ Define Data Structures:

Define a data structure named Sale. The structure has the following fields:

string itemName

int quantity

double unitPrice

double salePrice

Write Function Prototypes:

Write a function prototype for the function named loadData. The function receives an array of Sale as the first parameter and an int as the second parameter. The second parameter is for the size of the array. The function does not have any value to return.

Write a function prototype for the function named processData. The function receives an array of Sale as the first parameter and an int as the second parameter. The second parameter is for the size of the array. The function returns a double.

Write a function prototype for the function named printData. The function receives an array of Sale as the first parameter and an int as the second parameter. The second parameter is for the size of the array. The function does not have any value to return.

Write The Main Function

Define an int constant named SALES_SIZE and initialize it to 5.

Define an array named salesData that contains 5 Sale item using the named constant defined above as the size.

Call loadData and pass the array and size defined above.

Call printData to print the sales information on the screen.

Write Function Definitions

Function loadData

Write the block comment that describes the function name, what the function does, the parameters and the return value. In this case, simply write there is no returned value.

In the function body, load these data into the array received through the parameters.

"Milk", 1, 5.85

"Whole Wheat Bread", 2, 3.75

"Napkin", 3, 2.35

"Paper Towel", 3, 2.95

"Soap", 1, 1.95

Function processData

Write the block comment that describes the function name, what the function does, the parameters and the return value.

In the function body, iterate through the array received through the parameters to calculate the total sale price for each item and update the salePrice fields of the data structures.

The function should return the total price of the sale items contained in the array.

Function printData

Write the block comment that describes the function name, what the function does, the parameters and the return value. In this case, simply write there is no returned value. You must use manipulators on cout to format the output.

In the function body, call processData and pass the array received through the parameters to update the sale price for each item and calculate the total sale price of all the sale items contained in the array.

Iterate through the array received through the parameters and print the data according to the required format.

Test The Program

The output should look exactly as follows.

Sales Item Qty Unit Amt ======================================== Milk 1 5.85 5.85 Whole Wheat Bread 2 3.75 7.50 Napkin 3 2.35 7.05 Paper Towel 3 2.95 8.85 Soap 1 1.95 1.95 Total 31.20 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions