Write a C++ program to estimate your water bill for next quarter. 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:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Irvine Ranch Water District (adapted from irwd.com)

Write a C++ program to estimate your water bill for next quarter. 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)

  • Integer number between 1 to 12 inclusive for the month of the year.

  • Type of residence (user to enter character as follows):

    S – Single-family Residence C – Condo
    A - Apartment

    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 the month is entered out of range 1. . .12, 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 exit the program.

    CALCULA TE
    Calculate the amount of bill. This calculation is to be completed in three separate functions each called from main().
    FIRST CALCULATION FUNCTION to be called from main().
    Calculate budget (water allocation) for people. Allow 50 gallons per person, per day (assume a 30 day month).
    So if 4 people: 8.02 =50*people*30/748 =50*4*30/748

    SECOND CALCULATION FUNCTION to be called from main(). Then calculate budget for outdoor landscape:

Type of residence Single-family Residence Single Family Residence Condo
Condo
Apartment

Month budget 1, 2, 3, 4, 10, 11, 12 2.30 5, 6, 7, 8, 9 4.25 1, 2, 3, 4, 10, 11, 12 0.75 5, 6, 7, 8, 9 1.50 All months 0.00

THIRD CALCULATION FUNCTION to be called from main()
Budget Total = Total allocated = budget for people + budget for landscape

1

Calculate Cost as $1.53 per CCF used under or equal to their water budget and $5.15 per CCF on amount water used above their water budget.

OUTPUT Separate output function called from main() performs all output. A sample run might look like this:
Sample Run
Enter number of people in household: 4

Enter type of residence: ‘S’ for single family, ‘C’ for condo, or ‘A’ for apartment: s Enter Month 3
Enter Actual CCF used: 12.0

Budget for people and landscape: 10.32 Total cost: $ 25.14

THEME ISSUES

Functions (pass by value), IF Control Structures, character type

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> • Checkpoints

1) Include name, e-mail, and lab# as comment and print same to output

2) Minimum of three (3) comments in each function : Pre: (name and description of each parameter), Post: (what is being returned), and Purpose:(what the function does). Use Week 5 Canvas “Training Heart Rate: Beginning Code, Video, Code Complete” as your model for these statements. These comments demonstrate how well you are understanding function.

3) Use a globally defined constant for the allotment per person, i.e. 50 gallons.

4) 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 seciotn 6.15 of text.

5) One function which must be called from main() to calculate the budget based on number of people. Use C++ Style with prototype before main() and the function definition after main().

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.

2

6) One function which must be called from main() to calculate the budget for landscape. Use C++ Style with prototype before main() and the function definition after main().

7) One function which must be called from main() to calculate the bill total. Use C++ Style with prototype before main() and the function definition after main().

8) One function which must be called from main() to calculate the cost based on budget (calculated in previous function) and CCFs used. Use C++ Style with prototype before main() and the function definition after main().

8) Output must be formatted using dollar sign and 2 decimal place as shown on page 1.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY