CSCI 2170 OLA 4 This lab practices one dimensional array, as well as search and sort on 1D array. Write a
C++
program named "boxes.cpp" for this lab. An organization that your little cousin belongs to is selling low-fat cookies. If your cousin's class sells more cookies than any other class, the teacher has promised to take the whole class on a picnic. Of course, your cousins volunteered you to keep track of all the sales and determine the winner. Each class has an identification name, for example Dragon or Panda. Each sales slip has the class identification name and the number of boxes sold. Here is a sample of the data: Create two 1D arrays: one array named "classNames" to hold the identification names; and the other array named "boxes" to record the number of boxes sold. These two arrays are parallel arrays: the
i^(th )
element in the "classNames" array stores the class name whose total number of boxes sold is stored in the
i^(th )
element in the "boxes" array. Here is how to process the data file and add up the total number of boxes sold for each class: the first time a class name is read, store it in the next available element in the "classNames" array, and initialize the corresponding element in the "boxes" array by the number of boxes sold on that sales slip. Each subsequent time that class name is encounted, add the number of boxes sold to the corresponding array element in "boxes" array. With the data shown above, the two arrays would look like this once processed: classNames: boxes: After all the sales slips are processed, scan the "boxes" array to look for the largest value. The class name in the corresponding element in the "className" array is the name of the class that wins.