Question
Irvine Ranch Water District Write a C++ program to estimate your water bill for next month. Your water meter measures the volume of water you
Irvine Ranch Water District
Write a C++ program to estimate your water bill for next month. Your water meter measures the volume of water you use in hundreds of cubic feet (CCF). One CCF of water equals approximately 748 gallons.
INPUT
All input statements and their user prompts need to be in main() since pass by value only is being used in this lab. Your program is to prompt the user for:
- Number of residents in household (integer > 0)
- Type of residence (user to enter character as follows):
S Single-family Residence
C Condo
A Apartment
- Acutual number of CCFs used.
Program should not be case-sensitive. That is if user enters a lowercase s your program is to treat it as an uppercase S either by using toupper() function or through if statement.
If user enters a negative number for the number of residents, output an error message and exit the program. If letter other than s, S, c, C, a, or A is entered, output an error message and end the program.
CALCULATE
Calculate the amount of bill. This calculation is to be completed in two separate functions each called from main().
FIRST CALCULATION FUNCTION STEP 1:
Calculate budget for people. Allow 50 gallons per person, per day (assume a 30 day month).
So if 4 people: 50*people*30/748 =50*4*30/748 = 8.02
FIRST CALCULATION FUNCTION STEP 2:
Calculate water budget for outdoor landscape:
Type of residence | Budget for outdoor Usage |
Single-family Residence | 2.30 |
Condo | 0.75 |
Apartment | 0.00 |
Budget Total = budget for people + budget for landscape = 8.02 + 2.30 = 10.32
SECOND CALCULATION FUNCTION
Calculate Cost as $1.65 per CCF used under or equal to their water budget and $4.83 per CCF on amount water used above their water budget.
Example 1: Assuming Single Family Residence and 4 people: Budget = 8.02 + 2.30 = 10.32
Actual CCF used = 12.0: Cost = 1.65 * (10.32) + 4.83 * (12.0 10.32) = 25.14
OUTPUT All output is to be done from a separate function. Note: you might experience a 0.01 difference in rounding error.
A sample run might look like this:
Sample Run Example 2
Enter number of people in household: 3
Enter type of residence: S for single family, C for condo, or A for apartment: s
Enter Actual CCF used: 12.0
Budget for people and landscaape: 8.32
Total cost: $ 31.51
THEME ISSUES
Functions (pass by value), IF Control Structures, character type
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- Checkpoints Absolutely no arrays or structures. The problem is designed to be solved using primitive types only: int, float, double, char. Use only pass by value. Also, ABSOLUTELY NO GLOBAL VARIABLE DECLARATIONS. All variables need to be declared in main() or another function.
- Include name, e-mail, and lab# as comment and print same to output
- Minimum of three (3) comments in each function (Purpose: Pre: Post:) For how to write Pre/Post/Purpose watch the video and follow the model code posted on week 5 of Canvas: Code from Webinar - Training Heart Rate (Watch Video First).
- Use a globally defined constant for the allotment per person, i.e. 50 gallons.
- All input must be done in main(). Input may not be case sensitive. That is, if user enters s change it to S immediately. To do this use if() and assign uppercase value or you may use toupper() function (see 10.2 of text). Only an error message should be output and nothing more if data is erroneous (not S,s,C,c,A,a). Use exit() function as explained in section 6.15 of text.
- One function which must be called from main() to calculate the total budget. Use C++ Style with prototype before main() and the function definition after main().
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started