Write a program that prompts the user for their quarterly wa

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. Use the sample run below as a model for your output.

Solution

#include <stdio.h>

int main(void)
{
   int i,bill;
   float average,sum = 0;
   for(i=1;i<=4;i++) //input bill for 12 months or 4 quarters
   {
       printf(\"\ Please input your water bill for quarter %d\",i);
       scanf(\"%d\",&bill);
       sum = sum + bill;
   }
   average =sum/12; //average monthly bill
   printf(\"\ Your average monthly bill is $%.2f \",average);
  
   if(average > 75)
   printf(\"You are using excessive amount of water.\");
   else if(average > 25 && average < 75)
   printf(\"You re using a typical amount of water\");
   else if(average < 25)
   printf(\"Well done!!! You are conserving water\");
  
   return 0;
}

output:

 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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site