Advertisement
Sierra_ONE

Meter Reader

Oct 8th, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.01 KB | Source Code | 0 0
  1. /*
  2. 12. Meter Reader
  3. We need to start saving money people! I've noticed that we've been spending more money on electricity than everything else combined. In order for us to keep track of our electricity usage, we need to calculate our monthly costs based on our meter readings.
  4.  
  5. Cost:
  6. 0 to 100 kWh - P150.00
  7. 101 to 500 - P150.00 + 0.5 for each kWh over 100
  8. over 500 - P350.00 + 0.3 for each kWh above 500
  9.  
  10. Inputs
  11. 1. Rate of energy consumption in kWh
  12. */
  13.  
  14.  
  15. #include <stdio.h>
  16.  
  17. int main (){
  18.  
  19.     int kWh;
  20.  
  21.     printf("Enter the rate of consumption (kWh): ");
  22.     scanf("%d", &kWh);
  23.  
  24.     if (kWh <= 100){
  25.         printf("Total cost = P150.00");
  26.     }
  27.     else if (kWh <= 500){
  28.         int tot1 = kWh - 100;
  29.         float tot2 = tot1 * 0.5;
  30.         float tot3 = tot2 + 150;
  31.         printf("Total cost = P%.2f", tot3);
  32.     }
  33.     else {
  34.         int tot4 = kWh - 500;
  35.         float tot5 = tot4 * 0.3;
  36.         float tot6 = tot5 + 350;
  37.         printf("Total cost = P%.2f", tot6);
  38.     }
  39.  
  40.  
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement