Question

In: Computer Science

make a C++ program to calculate total water bill for a customer. The water company charges...

make a C++ program to calculate total water bill for a customer. The water company charges $250.00 for <=1000 gallons of water. Over 1000 gallons the company charges .99 / gallons

The program displays

Gallons of water used = xx

Exatra payment= xx

Total payment = xx

Solutions

Expert Solution

code:

#include <iostream>
using namespace std;

int main() {
int n;
float p=250.00,e; // Initially the payment value will be 250
cout << "Gallons of water used ="; // Inputs the gallons
cin >> n; // stores in the variable n
if(n<0) // if user enters n value less than 0 then p will be 0
p=0;
if (n>1000){ // if the gallons > 1000, the payment will be .99/gallon more to 250
p=250.00+(n-1000)*0.99;   
e=p-250.00; // varibale stores the extra payment
}
cout << "Extra payment = " << e << endl;
cout << "Total payment = " << p;
return 0;
}

Note:

* Here in second if, the condition is n>1000. And there is no code for n<=1000. For that the p value will be the default value 250 which is already declared.

outputs:

Gallons less than 1000

Gallons more than 1000

Thankyou


Related Solutions

make a C++ program to calculate discount for a customer. If customer code equals 1 discount...
make a C++ program to calculate discount for a customer. If customer code equals 1 discount = 5% Any other code discount = 2% Display the discount
C++ program: ABC Co wants you to develop a C++ program to calculate the total invoice...
C++ program: ABC Co wants you to develop a C++ program to calculate the total invoice based on the user inputs item price and the quantity of the item purchased, taking into consideration the discount given for each category as follow: Less than 10 Item: No discount Between 10 and 20 items: 10 % off the item price More than 20 items: 20% off the item price. Your Program should display, the total before discount, how much discount and the...
Design and implement a C++ program with functions to calculate the pre-tax charge: If the customer...
Design and implement a C++ program with functions to calculate the pre-tax charge: If the customer subscribes to a phone plan called Plan200, then he is charged $5 for the first 200 minutes. For each additional minutes, the customer will be charged $0.10. If the customer subscribes to a phone plan called Max20, then he is charged $0.05 for each minute up to $20. (I.e., the customer never needs to pay more than $20.) If the customer is not subscribed...
Using C++ Write a program to calculate the amount a customer should pay in a checkout...
Using C++ Write a program to calculate the amount a customer should pay in a checkout counter for the purchases in a bagel shop. The products sold are bagels, cream cheese, and coffee. Use the pseudo code discussed in the class to write the program. Make reasonable assumptions about the prices of bagel, cream cheese, and coffee. Declare prices of bagel, cream cheese, and coffee as constants.
Using C++ write a program to calculate the amount a customer should pay in a self...
Using C++ write a program to calculate the amount a customer should pay in a self checkout counter for his purchases in a bagel shop. The products sold are everything bagels, garlic bagels, blueberry bagels, cream cheese, and coffee. Using "doWhile loops" write the program to display the menu of the Bagel shop. Make the user buy multiple items of different choices. Finally display the total amount for the purchases. Below is my current code to work with. Please add...
Write a C++ program to calculate the time to drain a cylindrical water tank for an...
Write a C++ program to calculate the time to drain a cylindrical water tank for an initial water height ranging from 1 to 10 feet (specifically for 1, 2, 4, 6, 8, and 10 ft). The tank has a radius (rt) of 2 feet and the drain radius (rd) is 0.3 inch. The gravitational constant (g) is 32.2 feet/sec2. The formula for time to drain the tank is time=(rtrd)2h/vavg where, average velocity, vavg=0.5(2gh).5 In your program, assign the values to...
25.0 g of water cooled 10 C to -20 C. Calculate the total Energy change. With...
25.0 g of water cooled 10 C to -20 C. Calculate the total Energy change. With these useful numbers: ΔH fus = 334 J/g Δvap = 2260 J/g Cp for ice = 2.08 J/g ⁰C Cp for liquid water = 4.18 J/g ⁰C Cp for steam = 1.8 J/g ⁰C
C++ program Overloaded Hospital Write a c++ program that computes and displays the charges for a...
C++ program Overloaded Hospital Write a c++ program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an inpatient or an outpatient. If the patient was an inpatient, the following data should be entered: The number of days spent in the hospital The daily rate Hospital medication charges Charges for hospital services (lab tests, etc.) The program should ask for the following data if the patient was...
Calculate the total amount of heat needed to convert 76.3g of water from -27 C to...
Calculate the total amount of heat needed to convert 76.3g of water from -27 C to 109 C. Cice = 37.6 J/(mol x °C) ; CH2O(l) = 75.4 J/(mol x oC); CH2O(g) = 33.1 J/(mol x oC) ∆Hofus = 6.02 kJ/mol; ∆Hovap = 40.7 kJ/mol
Javascript Calculator Algorithm to calculate a tip percentage given the bill amount and total bill including...
Javascript Calculator Algorithm to calculate a tip percentage given the bill amount and total bill including tip. Asker suer for bill without tip: Ask the user for total bill with tip: Ask the user how many people splitting bill: Submit button to calculate the tip percentage
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT