Advertisement
rafikamal

Calculate Electric Bill

Jan 7th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. /* Line charge = 50 tk */
  2. /* For first 100 units, 1 unit = 5 tk */
  3. /* For next 400 units, 1 unit = 6.5 tk */
  4. /* For usage above 500 units, 1 unit = 8 tk */
  5.  
  6. #include <stdio.h>
  7.  
  8. int main()
  9. {
  10.     int unit;
  11.     double cost = 100;
  12.  
  13.     printf("Enter the number of units used: ");
  14.     scanf("%d", &unit);
  15.  
  16.     if(unit <= 100)
  17.         cost = cost + unit * 5;
  18.         else if(unit <= 500)
  19.             cost = cost + 100*5 + (unit - 100) * 6.5;
  20.         else
  21.             cost = cost + 100*5 + 400*6.5 + (unit - 500) * 8;
  22.  
  23.         printf("Total cost = %lf\n", cost);
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement