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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

THE PROGRAM SHOULD BE WRITTEN USING C++

CheckpointsAbsolutely 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.

# Irvine Ranch Water District

## Overview

The task is to write a C++ program designed to estimate your water bill for the upcoming month. The program utilizes your water meter, which measures water usage in hundreds of cubic feet (CCF). Notably, one CCF corresponds to approximately 748 gallons of water.

### Program Input Requirements

- All inputs and their corresponding prompts must be included within the `main()` function, as the lab exercise only allows for pass-by-value usage.
- Your program should request the following information from the user:
  - **Number of residents in the household**: This should be an integer greater than 0.
  - **Type of residence**: The user will input a character to specify the residence type:
    - `S` for Single-family Residence
    - `C` for Condo
    - `A` for Apartment
  - **Actual number of CCFs used**

### Important Considerations

- The program is designed to be case-insensitive. For instance, if a user enters a lowercase `s`, the program should process it as an uppercase `S`. This can be achieved by employing the `toupper()` function or using an `if` statement.
- If the user inputs a negative number for the number of residents, the program should display an error message and terminate.
- Similarly, if the user enters any letter other than `S`, `s`, `C`, `c`, `A`, or `a`, an error message should be displayed, and the program should end.

By following these guidelines, the program will accurately estimate the user's water bill based on their actual usage, residence type, and household size.
Transcribed Image Text:# Irvine Ranch Water District ## Overview The task is to write a C++ program designed to estimate your water bill for the upcoming month. The program utilizes your water meter, which measures water usage in hundreds of cubic feet (CCF). Notably, one CCF corresponds to approximately 748 gallons of water. ### Program Input Requirements - All inputs and their corresponding prompts must be included within the `main()` function, as the lab exercise only allows for pass-by-value usage. - Your program should request the following information from the user: - **Number of residents in the household**: This should be an integer greater than 0. - **Type of residence**: The user will input a character to specify the residence type: - `S` for Single-family Residence - `C` for Condo - `A` for Apartment - **Actual number of CCFs used** ### Important Considerations - The program is designed to be case-insensitive. For instance, if a user enters a lowercase `s`, the program should process it as an uppercase `S`. This can be achieved by employing the `toupper()` function or using an `if` statement. - If the user inputs a negative number for the number of residents, the program should display an error message and terminate. - Similarly, if the user enters any letter other than `S`, `s`, `C`, `c`, `A`, or `a`, an error message should be displayed, and the program should end. By following these guidelines, the program will accurately estimate the user's water bill based on their actual usage, residence type, and household size.
**Calculation of Bill Amount**

This calculation will 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 (assuming a 30-day month).
- Example for 4 people:  
  \[
  50 \times \text{people} \times 30 / 748 = 50 \times 4 \times 30 / 748 = 8.02
  \]

**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 Calculation:**
\[
\text{Budget Total} = \text{budget for people} + \text{budget for landscape} = 8.02 + 2.30 = 10.32
\]

### Second Calculation Function

Calculate cost as follows:
- $1.65 per CCF used under or equal to their water budget.
- $4.83 per CCF on the amount of water used above their water budget.
Transcribed Image Text:**Calculation of Bill Amount** This calculation will 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 (assuming a 30-day month). - Example for 4 people: \[ 50 \times \text{people} \times 30 / 748 = 50 \times 4 \times 30 / 748 = 8.02 \] **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 Calculation:** \[ \text{Budget Total} = \text{budget for people} + \text{budget for landscape} = 8.02 + 2.30 = 10.32 \] ### Second Calculation Function Calculate cost as follows: - $1.65 per CCF used under or equal to their water budget. - $4.83 per CCF on the amount of water used above their water budget.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education