Advertisement
fahimkamal63

Electricity bill

Oct 20th, 2019
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. //  Electricity bill
  2. //  Date : 20.10.19
  3. #include<stdio.h>
  4.  
  5. int main(){
  6.     printf("Enter the used electric unit: ");
  7.     int unit;
  8.     scanf("%d", &unit);
  9.     double bill = 0;
  10.     if(unit > 250){
  11.         bill = (50 * 0.50) + (100 * 0.75) + (100 * 1.20) + ((unit - 250) * 1.50);
  12.     }
  13.     else if(unit > 150){
  14.         bill = (50 * 0.5) + (100 * 0.75) + ((unit - 150) * 1.20);
  15.     }
  16.     else if( unit > 50){
  17.         bill = (50 * 0.5) + ((unit - 50) * 0.75);
  18.     }
  19.     else bill = unit * 0.5;
  20.  
  21.     bill = bill + ((20 * bill) / 100);
  22.  
  23.     printf("%f", bill);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement