Write a C Program for to calculate the water bill given the cubic feet of water used for Eureka Water Company, which charges the homeowner one of the following:
A flat rate of $15.00 for usage up to and including 1000 cubic feet.
$0.0175 per cubic foot for usage over 1000 cubic feet and up to and including 2000 cubic feet.
$0.02 per cubic foot for usage over 2000 cubic feet and up to and including 3000 cubic feet.
A flat rate of $70.00 for usage over 3000 cubic feet.
CODE:
#include<stdio.h>
main ()
{
int flat_size=0;
float price=0.0;
printf("Enter your flat size:");
scanf("%d",&flat_size);
if(flat_size<=15)
{
printf("your flat rate is 15$");
}
else if(flat_size>1000 && flat_size<=2000)
{
price=0.0175*flat_size;
printf("your flat rate is %f$",price);
}
else if(flat_size>2000 && flat_size<=3000)
{
price=0.02*flat_size;
printf("your flat rate is %f$",price);
}
else
{
printf("your flat rate is 70$");
}
return 0;
}
Program Output:
No comments:
Post a Comment