Question: IN C++ you are to write a program that reads sales data from a text file, sorts the data and outputs the sorted data to

IN C++

you are to write a program that reads sales data from a text file, sorts the data and outputs the sorted data to a second file. The input file is a comma-seperated value file (CSV), with the first item being the number of sales data items to be processed, followed by the list of sales data on one line (items are seperated by commas).

Task 1: Algorithm

Exercise 1.Write a high-level algorithm of your program listing the major steps in pseudocode. Then refine each major step into a sequence of steps, each readily translatable into C++ code.

Decide which steps should be done by the function main() and which steps can be delegated to separate functions. You want your program to be modular and you also want to reuse generic functions. For example, the sorting of the list can be done by the selectionSort() function you wrote in a previous lab.

Make a decision on how to best represent the sales data.

Exercise 2.Design a test data set to verify your algorithm and test your program later.

Task 2: Coding

Translate your algorithm into a C++ program. You program should have at least three functions, in addition to main():

a function (getSalesData) to read the sales data form the input file and store it in an array of the appropriate size. A major decision to make here is where to get the size of the array. You have two options: 1) ask the user in function main() to enter the data size, create a dynamic array in main(), and then call function getSalesData with the name of the array and its size to get the data, or (2) function does all of the above (i.e. prompt use to enter the size of the data, create the array, read the data) and return the array and its size (you to figure out how).

a function to sort the data in ascending order

a function to write the sorted data into the output file (Note: output file should have the same format as the input file except that the sales data is sorted)

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!