179k views
2 votes
Write a c++ program to compute a water andsewage bill. The inputis the number of gallons consumed. The bill is computed asfollows:

water costs .21dollars per gallon of water consumed

sewage service .01dollars per gallon of water consumed

1 Answer

6 votes

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

//initialization

float gallonConsume;

//print the message

cout<<"Enter the number of gallons consumed: ";

cin>>gallonConsume; //read the input

float waterCost = 0.21 * gallonConsume; //calculate the water cost

cout<<"The water cost is: "<<waterCost<<endl; //display

float sewageService = 0.01 * gallonConsume; //calculate the sewage service cost

cout<<"The sewage service cost is: "<<sewageService<<endl; //display

return 0;

}

Step-by-step explanation:

Include the library iostream for using the input/output instruction.

Create the main function and declare the variables.

then, print the message on the screen by using cout instruction.

the value enters by the user is read by cin instruction and store in the variable.

After that, calculate the water cost by using the formula:


Water\,cost = 0.21 * water\,consume

then, display the output on the screen.

After that, calculate the sewage service cost by using the formula:


sewage\,service\,cost = 0.01*water\,consume

finally, display the output on the screen.

User Patrick Fromberg
by
8.0k points