Write a Program in C++ Which Compute Monthly Water Bill

In this Program we will calculate the Monthly Water Bill . This Problem Concern with Mathematical Problem and Solutions and for Calculating this we Need Previous Unit and Current Unit price of bill .When we Subtract Previous Units From Current Units we Get the Monthly Units of Water.

Source Code

#include <iostream>
using namespace std;
int main ()
{
 cout<<endl<<endl<<"*************** WATER BILL CALCULATION ***************"<<endl<<endl;
 char ch;
 do
 {
  int previous_meter_reading;                //Declare the Variable
  int current_meter_reading;       //Declare the Variable
  int demand_charge=350;        //Intilize the Variable
  int charge_per_gallon=10;       //Intilize the Variable
  int surcharge=50;         //Intilize the Variable
  int gallons;          //Declare the Variable 
  int bill;           //Declare the Variable
   char unpaid_balance;        //Declare the Variable
  cout<<endl<<"Please Enter Previous Meter Reading: ";
  cin>>previous_meter_reading;      // User Input the Last Record Unit
  cout<<endl<<"Please Enter Current Meter Reading: ";
  cin>>current_meter_reading;       // User Input the Current Record Unit
  cout<<endl<<"Did Customer Paid The Previous Bill? (Press 'Y' or 'N'): ";
  cin>>unpaid_balance;        //User Can Pay the Last bill or not
  gallons=current_meter_reading-previous_meter_reading;
  if (unpaid_balance== 'Y')       // If yes then it subtracted from current one
  {
   bill=(charge_per_gallon*gallons)+demand_charge;
  }
  else
  {
   bill=(charge_per_gallon*gallons)+demand_charge+surcharge; // If not then it subtracted from current one
  }
  cout<<endl<<"Water Bill="<<bill<<"Rs."<<endl;    
  cout<<endl<<"=============================================================="<<endl;
  cout<<"Do you Want More (Y / N) : ";    //Asking 4 more if not then press N and Exist Programme
  cin>>ch;
 }while(ch=='y--');
return 0;
}

Output of the Program


Compute Water Billing System

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.

2 comments:

  1. plz upload the large project of software like banking system voting management etc ,,, for for that

    ReplyDelete
  2. Actually have gained a knowledge of this notes

    ReplyDelete