ELECTRICITY BILL CALCULATOR
Code :
#include<stdio.h>
int main()
{
float unit = 0, bill = 0, total_bill = 0,fixed = 102;
printf("=============================================\n");
printf("\t\tELECTRICITY BILL\n");
printf("=============================================\n");
printf("Enter your power consumption (In unit): ");
scanf("%f", &unit);
printf("\n");
if(unit <= 100)
{
bill = unit * 3.44;
}
else if(unit <= 300)
{
bill = 344 + ((unit - 100) * 7.34);
}
else if(unit <= 500)
{
bill = 1812 + ((unit - 300) * 10.36);
}
else if(unit <= 1000)
{
bill = 3884 + ((unit - 500) * 11.82);
}
else if(unit > 1000)
{
bill = 9794 + ((unit - 1000) * 11.82);
}
total_bill = bill + fixed;
printf("Your power consumption bill to be paid is\n %.2f rupees\n", total_bill);
printf("----------------------------------------------\n");
return 0;
}
Come again Learn again !
« iCodeBuzz »
No comments:
Post a Comment