Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ console application to generate an item report. The program will use arrays and functions. You must use all functions in your program.

image text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

Write a C++ console application to generate an item report. The program will use arrays and functions. You must use all functions in your program. Your program should read data from an input file and write the report to the output file. The program should ask the user to enter the name of both the input file and the output file. The output file will contain the activity report. DO NOT HARD CODE THE NAMES OF THESE FILES IN THE PROGRAM. IT WILL BE MARKED AS INCORRECT IF THE FILENAMES ARE HARD CODED INTO THE PROGRAM. Again, ask the user to enter both the input and output filenames and then use those files respectively for input and output (sample execution below). In main you will need to declare four arrays. There need to be arrays for the following: An array to hold all the names An array to hold the prices An array to hold the quantities An array to hold the discount percentages Name Array 0-Soda 1-Apple 2-Sandwich 3 - Brownie Price Array 0-1.50 1 -0.75 -6.50 3-3.50 Quantity Array 0-4.00 1-3.00 2-2.00 3-1.00 Discount Pct Array 0-0.10 1-0.00 2-0.25 3-0.10 Sandwich data are located at index 2 of each array 2 These are parallel arrays. All data for one item are located at the same index in each array. For example, all data for Sandwich are located at index 2 of each array. You will need to create an input data file for the program (see format below). Make sure you split up the code into appropriate header files (.h) and source files (.cpp). All function prototypes should be in another header file (.h). All function definitions should be in one source file (.cpp). The main function should be in yet another source file (.cpp). Name Array 0-Soda 1 - Apple 2-Sandwich 3 - Brownie Price Array 0-1.50 1 -0.75 2-6.50 3-3.50 Quantity Array 0-4.00 1-3.00 2-2.00 3-1.00 Discount Pct Array 0 -0.10 1 -0.00 2-0.25 3-0.10 Sandwich data are located at index 2 of each array | These are parallel arrays. All data for one item are located at the same index in each array. For example, all data for Sandwich are located at index 2 of each array. You will need to create an input data file for the program (see format below). Make sure you split up the code into appropriate header files (.h) and source files (.cpp). All function prototypes should be in another header file (.h). All function definitions should be in one source file (.cpp). The main function should be in yet another source file (.cpp). Functions Here are the functions to create: C++ Function Name Purpose ReaditemsFromFile Reads item data from the given filename and populates multiple arrays of data. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN. Only reads from the input file. Parameters(5): inputfilename, name array, price array, quantity array, and discount percentage array. Return Type: void ItemReport Writes an item report to a given output filename. The report should be formatted the same as the example report given below. You should use columns in the body of your report (setw). Inside this function it should call the FindMaxPricelndex, Find MinPriceindex, Calculate Avg Price, and Calculate TotalPrice functions to get data to write in the report. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN. Only write to the output file. Parameters(5): outputfilename, name array, price array, quantity array, and discount percentage array. Return Type: void FindMaxPricelndex Searches the price array for the maximum price amount. It should return the index of the maximum price. It should set the maximum price reference parameter to the maximum price in the array. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN. Parameters(2): price array, maximum price (pass by reference) Return Type: int Find MinPricelndex Searches the price array for the minimum price amount. It should return the index of the minimum price. It should set the minimum price reference parameter to the minimum price in the array. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN. Parameters(2): price array, minimum price (pass by reference) Return Type: int Calculate Avg Price Calculates the average price for the array. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN. Parameters(1): price array Return Type: double Calculate TotalQuantity Calculates the total quantity for the array. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN. Parameters(1): quantity array Return Type: double Input Data File Format Item Name Item Price ItemQuantity Item Discount Item Name Item Price Item Quantity Item Discount Sample Input Data File (notice there is no descriptive text, just the data) Soda 1.5e 1 Record Apple 0.75 1 Record Sandwich 6.50 1 Record .25 Brownie 3.50 1 Record Sample Report File (1 record per line in report) Item Report Name Price Quantity Discount Pct Soda Apple Sandwich Brownie 1.50 0.75 6.50 3.50 4.ee 3.ee 2.00 1.00 0.10 0.00 0.25 9.16 Average Price: 3.06 Total Quantity: 10 Max Price Item Name: Sandwich Max Price Amount: 6.50 Min Price Item Name: Apple Min Price Amount: 6.75 Sample Program Execution

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 Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions