Meat Purchases Report

How can a grocery store owner keep track of customers' meat purchases?

The grocery store owner wants to monitor how many pounds of Red Meat each of its 3 customers buys each day during a typical week. Write a program that stores this information in a two-dimensional 3 x 3 array, where each row represents a different customer and each column represents a different day of the week. The program should input the data for each customer and create a report with the average amount of meat purchased per day by all customers, the least amount purchased during the week by any customer, and the most amount purchased during the week by any customer.

Solution

To solve this problem, we can use a two-dimensional array to store the amount of red meat purchased by each customer for each day of the week. The array will have 3 rows (representing the 3 customers) and 3 columns (representing the 3 days of the week).

Here's a step-by-step solution:

Step-by-Step Solution:

1. Declare a two-dimensional array with 3 rows and 3 columns to store the red meat purchases.

2. Prompt the grocery store owner to input the amount of red meat purchased by each customer for each day of the week.

3. Validate that the entered amount is non-negative. If a negative value is entered, prompt the owner to re-enter a non-negative value.

4. Calculate the average amount of meat purchased per day by all 3 customers.

5. Find the least and most amount of meat purchased during the week by any of the customers.

6. Print out the report including the average amount of meat purchased per day, the least amount purchased during the week, and the most amount purchased during the week.

7. Implement two functions for input validation and calculation of average, minimum, and maximum values.

8. Add comments throughout the code for better understanding and organization.

← How to save a file as a pdf to a specific folder How to handle external technical specialist in scrum teams →