Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Project #2 - vector utilization, sorting, and algorithm development Design and implement a computer based solution (program) using vectors for the following requirements: 1. Read
Project \#2 - vector utilization, sorting, and algorithm development Design and implement a computer based solution (program) using vectors for the following requirements: 1. Read in a series of sales dollar amounts and cost dollar amounts from a file that are tab separated (tab delimited), and store the amounts in two (2) vectors. 2. Sort both of the vectors from lowest to highest. The price and cost will coincide when sorted. 3. Output the sorted lists of sales and costs to the console window, in two (2) columns right aligned, and the sum for each column. Use " \t ", setw( x), and include dollar signs and precision as appropriate. The totals may be computed in the output function. a. EXTRA CREDIT (10 Points): Compute the profit for each sale and output to a third column in the console window along with the sum of the profit. The profits may be computed in the output function. 4. Required functions called from main and included in a header file: (1) opening the input file with error handling (shown below), (2) reading the input and storing the values in vectors, (3) output to the console window. Sort may be called from main using the vector sort function shown below. The function definitions are to be in the header file. 5. Create the input file named "sales_and_cost_amounts.txt" and add the following values in the order that they appear in two (2) columns with a tab between them. The sale price is in the left column and cost is to the right. Use them to compute profit for extra credit. Main shall only have declarations for the variables, stream, and vectors, function calls, and file closing. Lab references: Declaring a vector - page 437 Vector push_back function - page 441 Vector size - page 443 NOTE: vectors are passed by reference to change them The vector sort function requires \#include , and has two (2) arguments: the beginning and the end as shown here. sort(vectorName.begin(), vectorName.end()); 1 Assignments submitted after the due date will incur a grade penalty of three (3) points per day after the first day, and will not be accepted more than one (1) week late
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