Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 andor tab characters
You are responsible for running your code through the autograder 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:
Defines constexpr int NUMSALESPEOPLE to store the current number of employees.
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
Declares an std::vector of these structs with NUMSALESPEOPLE entries.
Done for you in main.cpp Opens the stream text file named salesdata.txt If the file cannot be opened, then a descriptive error message is displayed, and execution terminates abnormally.
Reads each line of the salesdata.txt file into a separate entry of the array.
Compute the combined weekly sales as well as the maximum individual sales amount while reading the salesdata.txt file.
Displays the combined and maximum weekly sales on the console:
Combined weekly sales is $
Maximum weekly sales is $
Be sure to read comments in the code providing guidance on what needs to be added. CMakeLists.txt takes care of copying salesdata.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
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 commission on their sales amount. In addition, the salespeople with the maximum weekly sales there could be more than one receive a $ bonus. Payments should be rounded to the nearest dollar:
Combined weekly sales is $
Maximum weekly sales is $
Sales staff payments are:
Justin Blake $
Rachel Davide $
Colin Forth $
Diana Ince $
Carol Marsh $
Emma McNish $
Phil Morgan $
Sue Parsons $
Boris Pullman $
Dan Terry $
Tab t characters are used to line up the columns.
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