Question: Write a C function (not a whole program) called calcPrices that will calculate final prices in a fishing/camping store. Your colleagues have written several functions

Write a C function (not a whole program) called calcPrices that will calculate final prices in a fishing/camping store. Your colleagues have written several functions for applying discounts to a single product. Theyd like your function to be able to call any one of their functions for each product. Your function must also ensure that the price remains positive. It should disregard any discounts that would make the price zero or negative. Your function must return nothing, and accept the following parameters: nCategories The number of categories of products. averageDiscount The average discount applied to all products across all categories (as a pointer, for export purposes). discountCalc A pointer to one of your colleagues discounting functions. All of their functions takes a pointer to a float, representing a price. The function updates (reduces) the value stored at that location, or leaves it alone. The function returns nothing. Each product category contains a number of different types of products. Categories are identified by an integer index, between zero and nCategories minus one. Within each category, products are also identified by an integer index, starting at zero. Your function must step through each product in each category, setting the new price. Your function should also calculate the average discount. You will need to use three more functions which are provided for you. ie you do not need to write these:

To retrieve the number of different types of products in a category: int getNProducts(int category); To retrieve the original product price: float getPrice(int category, int product); To set the new price: void setPrice(int category, int product, float newPrice); Use the following blank pages to answer this question. Ensure your code conforms to the standards . Hint: write pseudo code first! Also, space out your answer as much as possible. You can amend your answer to insert extra code, but you must make it neat and legible. There are two blank pages for working out.

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!