Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C++ console application to generate a sales report. The program will use multiple arrays and functions. You must use all functions in your
Write a C++ console application to generate a sales report. The program will use multiple 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 three arrays. One for sales figures, one for first names, and one for last names. You will need to get the filenames from the user in main 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 ReadSalesFromFile Reads sales 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(4): inputfilename, first name array, last name array, and sales array Return Type: void Writes a sales 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 FindMaxSaleslndex, FindMinSalesindex, CalculateAvgSales, and CalculateTotalSales functions to get data to write in the report. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN. Only write to the output file. SalesReport Parameters(5): outputfilename, first name array, last name array sales array, number of element in array. Return Type: void FindMaxSalesIndex Searches the sales array for the maximum sales amount. It should return the index of the maximum sales. It should set the maximum sales reference parameter to the maximum sales in the array. This function should not print anything on screen. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN Parameters(3): sales array, number of element in array, maximum sales (pass by reference) Return Type: int FindMinSalesIndex Searches the sales array for the minimum sales amount. It should return the index of the minimum sales. It should set the minimum sales reference parameter to the minimum sales in the array. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN Parameters(3): sales array, number of elements in array, minimum sales (pass by reference). Return Type: int CalculateAvgSales Calculates the average sales for the array. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN Parameters(2): sales array, number of element in array Return Type: double CalculateTotalSalesCalculates the total sales for the array. THIS FUNCTION SHOULD NOT PRINT ANYTHING ON SCREEN Parameters(2): sales array, number of element in array Return Type: double Sample Report File (1 record per line in report) Sales Report First Last Sales Smith Diaz John il11ams Johnson Davis Jane Rose 180.06 260.00 150.00 250.06 75.00 Felicia Ron Average Sales: 155.88 Total Sales: 775.00 Max Sales Name: Felicia Johnson Max Sales Amount: 258.08 Min Sales Name: Ron Davis Min Sales Amount: 75.80 Sample Program Execution nter the input filename: sales.txt nter the output filename: rep.txt Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started