The city of Paris, Texas tracks how much water is consumed by its citizens on a monthly basis. The City Manager would like statistics about the consumption. She would like to know the months with the highest and lowest consumption, the yearly average, and the yearly total. NOTE: Water consumption is measured in CCF (centum cubic feet)
The main function should:
Create an array to store the twelve months of consumption.
Call the following functions, passing the array to all but the print headers function:
- Get data from user: The function should use a loop to ask the user for the amount consumed for 12 months, using the appropriate month name and store the data in the consumption array.
Input Validation: Do not accept negative numbers.
Your screen dialog might look similar to this (user input is shown in bold):
|Enter water consumption in CCF for January: 500000
Enter water consumption in CCF for February: 400000
- Print the headers: which should ask for the year of the report to be displayed in the header and print the headers. Input Validation: The year should be validated to be between 2005 and 2020.
- Display the consumption: Using the data from the consumption array, display the consumption for the year for each month with appropriate month labels.
- Get lowest consumption: Using the data from the consumption array, determine the month with the lowest consumption, print the month name and the amount of the consumption for that month.
- Get highest consumption: Using the data from the consumption array, determine the month with the highest consumption, print the month name and the amount of the consumption for that month.
- Get total and average consumption: Using the data from the consumption array calculate the total and average of all months for the year and print them.
| 2016 Consumption Report for Paris, Texas
Month Consumption in CCF
The lowest consumption was in March with 100000 CCF
The highest consumption was in July with 900000 CCF
The total consumption for the year: 2000000 CCF
The average consumption for the year: 500000 CCF
Modularity Your program must be a modular program. Your main function should not contain any loops. It should call all of the functions described above, calling a total of 6 functions
- Do not use global variables in any assignment. A global variable is a variable that is declared outside any function. It is okay to use global constants.
- When passing the array to a function that does not modify it, use the const keyword to prevent any modification to the array.
- To find the minimum and maximum values sort the array first.