Introduction to Computer Science I Project #2 -vector utilization, sorting, and algorithm development Design and implement...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Introduction to Computer Science I 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 (15 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 sales_and_cost_amounts.txt - Notepad File Edit Format View Help 29.95 24.26 3.55 3.27 34.70 26.72 12.34 10.61 21.40 17.33 2.67 2.46 33.89 26.10 8.98 8.26 24.99 20.24 18.45 15.87 4.99 4.59 15.95 13.72 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 Introduction to Computer Science I 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 (15 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 sales_and_cost_amounts.txt - Notepad File Edit Format View Help 29.95 24.26 3.55 3.27 34.70 26.72 12.34 10.61 21.40 17.33 2.67 2.46 33.89 26.10 8.98 8.26 24.99 20.24 18.45 15.87 4.99 4.59 15.95 13.72 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
Expert Answer:
Answer rating: 100% (QA)
The detailed answer for the above question is provided below Solution All the functions in the given ... View the full answer
Related Book For
Modern Systems Analysis And Design
ISBN: 9780134204925
8th Edition
Authors: Joseph Valacich, Joey George
Posted Date:
Students also viewed these programming questions
-
Read the following facts and then choose the correct option below: X acts as an interpreter in a transaction where Y wants to buy stolen goods from Z. X's conduct is considered to be that of a/an: a....
-
Estimate the theoretical fracture strength of a brittle material if it is known that fracture occurs by the propagation of an elliptically shaped surface crack of length 0.5 mm (0.02 in.) and a tip...
-
Identify whether each of the following would be reported as an operating, investing, or financing activity on the statement of cash flows. a. Payment of accounts payable d. Issuance of common stock...
-
Harold, a board member of a Fortune 500 corporation, has just discovered at a board meeting that the company will acquire a competitor and that the company stock will likely increase once this...
-
Pamelas Quilt Shoppe sells homemade Amish quilts. Pamela buys the quilts from local Amish artisans for $ 240 each, and her shop sells them for $ 410 each. She also pays a sales commission of 4% of...
-
5 Which one of the following correctly represents Sodium oxide? +2 XX a) Na 20 XX 6) 2NaOx x; 1-2 'xx' 1-2 c) 2 Na 20% c) Na XX XX 6 An element with atomic number_ will form a basic oxide. a) 7 (2,5)...
-
During 2018, Mings Book Store paid $486,000 for land and built a store in Naperville, Illinois. Prior to construction, the city of Naperville charged Mings $1,000 for a building permit, which Mings...
-
Cells occur at a range of sizes, but the components of which they are composed (biological macromolecules and other materials) do not change sizes; rather the individual molecules will be of...
-
What are some of your everyday activities that require the use of business communications? - What is likely to happen if a business does not communicate effectively with its customers? - Why does...
-
COURSE CID COURSETITLE CREDIT 1 MATH2 2 PHISIC2 3 LITERATURE PREQ CID PRE-REQUISITE 1 MATH1 2 FISIC 1 3 4 ENGLISH1 5 ENGLISH1 6 FRENCH1 Create the following Queries from the tables above 1. What are...
-
In the video, The Art of Following (2017), Dr. Bentley shares the connection of leader and follower through music. In essence, she is teaching the audience followership. Similarly, Northouse (2022)...
-
5. A 0.46 kg dynamics cart is held at rest next to a Hooke's Law spring that is compressed by 0.42 m. The spring has a force constant of 120.0 N/m. The cart is released and travels along a horizontal...
-
Write a program (using C program) to simulate a simple lottery engine. The user must enter 5 integer numbers, within the range of 10 to 30. The lottery engine must validate that all the numbers...
-
Winston Company had two products code named X and Y. The firm had the following budget for August: Product X Product Y Total Sales $ 276,000 $ 460,000 $ 736,000 Variable Costs 194,000 230,000 424,000...
-
A non-charmed baryon has strangeness S = 2 and electric charge Q = 0. What are the possible values of its isospin I and of its third component I z ? What is it usually called if I = 1/2?
-
Building on the research conducted in Problem and Exercise 12-53, what challenges does each device present for designers when delivering an electronic commerce application? Are some devices more...
-
Describe several input devices for interacting with a system. Is one device better than all others? Why or why not?
-
Contrast the following terms: a. Subtype; supertype b. Total specialization rule; partial specialization rule c. Disjoint rule; overlap rule d. Attribute; operation
-
Describe the role of a paralegal in a family law practice.
-
Define family law and identify the kinds of issues that are addressed in a family law practice.
-
Identify the kinds of resources included in a basic family law library.
Study smarter with the SolutionInn App