Question: This assignment involves manipulating structured data, similar to what might be analyzed with a spreadsheet. Spreadsheet rows are typically indexed with an integer, and the

This assignment involves manipulating "structured" data, similar to what might be analyzed with a spreadsheet. Spreadsheet rows are typically indexed with an integer, and the columns are assigned names. An array of structs is accessed similarly.
Part 1
Every week a company generates a text file containing one line per salesperson. The lines contain the salesperson's first name, last name, and their total weekly sales. These three fields are separated by "white space" (blanks and/or tab characters).
You are responsible for running your code through the auto-grader using the link at the bottom of this page.
Add C++ code to the solution() function in code.cpp and to the main() function in main.cpp that:
1. Defines constexpr int NUM_SALESPEOPLE to store the current number of employees.
2. Defines a struct containing a first name field (a std::string), a last name field (also a std::string), and a weekly sales data field (a double). Note that this is a different struct that is already defined in code.hpp. The struct PaymentInfo will be used in Part 2.
3. Declares an std::vector of these structs with NUM_SALESPEOPLE entries.
4.[Done for you in main.cpp] Opens the stream text file named sales_data.txt. If the file cannot be opened, then a descriptive error message is displayed, and execution terminates abnormally.
5. Reads each line of the sales_data.txt file into a separate entry of the array.
6. Compute the combined weekly sales as well as the maximum individual sales amount while reading the sales_data.txt file.
7. Displays the combined and maximum weekly sales on the console:
Combined weekly sales is $20892.6
Maximum weekly sales is $4523.11
Be sure to read comments in the code providing guidance on what needs to be added. CMakeLists.txt takes care of copying sales_data.txt from the source code directory to the build subdirectory so that you don't have to do that manually. Look over CMakeLists.txt, which is mostly readable.
Part 2
Add the following functionality to the first part: Use the array to compute the weekly payment to each salesperson and display it on the console. The payment is a 10% commission on their sales amount. In addition, the salespeople with the maximum weekly sales (there could be more than one) receive a $200 bonus. Payments should be rounded to the nearest dollar:
Combined weekly sales is $20892.6
Maximum weekly sales is $4523.11
Sales staff payments are:
Justin Blake $323
Rachel Davide $413
Colin Forth $652
Diana Ince $310
Carol Marsh $98
Emma McNish $104
Phil Morgan $0
Sue Parsons $172
Boris Pullman $210
Dan Terry $6
Tab ('\t') characters are used to line up the columns.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!