Wednesday, 26 August 2015

Write a program that prompts the user for their quarterly water bill for the last four quarters. The program should find and output their average monthly water bill. If the average bill exceeds $75, the output should include a message indicating that too much water is being used. If the average bill is at least $25 but no more than $75, the output should indicate that a typical amount of water is being used. Finally, if the average bill is less than $25, the output should contain a message praising the user for conserving water.

# include<iostream>

using namespace std;
void main()
{
       int sum=0, quarter ; float avg;
       cout<<"please enter your water bill for quarter 1  :";
       cin>>quarter;
       sum=sum+quarter;
       cout<<"please enter your water bill for quarter 2  :";
       cin>>quarter;
       sum=sum+quarter;
       cout<<"please enter your water bill for quarter 3  :";
       cin>>quarter;
       sum=sum+quarter;
       cout<<"please enter your water bill for quarter 4  :";
       cin>>quarter;
       sum=sum+quarter;
       avg=float(sum)/4;
       cout<<"your average monthly bill is "<<avg<<"$.";
       if(avg>75)
               cout<<"you are using excessive amounts of water."<<endl;
       else if(avg>=25 && avg <75)
               cout<<"you use a typical amount of water"<<"\n";
       else
               cout<<"Good you use a very small amount of water.\n Thanks for saving water.";

system("pause");
}

2 comments:

  1. avg=sum/12 , sum will be divided by 12 because 1 quarter represent 3 month so in the same way 4 quarter represents 12 months .

    ReplyDelete