Question: A local vitamin store gathered some data in a file for protein powders. The store manager would like to be able to recommend product to

 A local vitamin store gathered some data in a file for

A local vitamin store gathered some data in a file for protein powders. The store manager would like to be able to recommend product to customers based on customer reviews. The file has the following format (the first line is not included in the file) InStock #of Reviews Brand 150 53 units Sold Avg. Customer Review 790 Optimum Nutrition 25 3.8 BSN The numbers represents the number of units in stock at the drugstore, and units sold for the past six months, the average customer review, and the number of reviews, followed by the brand name Write a program that read in the data from a file and sort the protein powders by average customer review. The output file contains the list of top 5 recommended protein powders (top 5 by average customer review with 50 or more reviews, and currently in stock). The list of recommended protein powders should be written the same file name as the input file name with added extension of .rcd. For example, if the original file name is protein.txt, the output file name is then protein.txt.rcd. Input file name should be obtained from the command line. For example, if the file name is protein.txt, you will run the program as: 1. ./a.out protein.txt Read the data using fscanf function. To read the brand name (last item in a line), use "% [ ^ ] " as the conversion specifier for fscanf function. Define a structure protein to store the brand (string), unitsinStock (integer), and unitsSold (integer), and avg. customer review (double), number of reviews (integer). Assume the brand is no more than 100 characters Build an array of protein structures. Assume that there are no more than 100 protein powders in the file Modify the selection_sort function to sort an array of protein powders in descending order, sorted by avg. customer review. The function should have the following prototype: 2. 3. 4. 5. void selection_sort (struct protein protein_powders[i, int n); 6. The output file contains the list of top 5 recommended protein powders (top 5 by average customer review with 50 or more reviews, and currently in stock) in the same format as the input file but in sorted order by average customer review

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!