Calculate Electricity Bill by using C programming !!

 An electricity board charges the following rates for the use of electricity:

For the first 200 units : 80 P per unit

For the next 100 units : 90 P per unit

Beyond 300 units : Rs 1.00 per unit 

All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more than Rs. 400,then an additional surcharge of 15 % of total amount is charged.

Write a program to read the names of users and number of units consumed and pint out the charges with names.

Solve :-

#include <stdio.h>

#include <stdlib.h>

#include <ctype.h>

#include <string.h>

#include <math.h>

int main() {

   float unit,bill,amnt1,amnt2,amnt3,tbill,ubill;

   //tbill= bill + service charge 

   //ubill = Ultimate bill 15% VAT included

   

   printf("Enter the unit : \n");

   scanf("%f",&unit);

   amnt1=unit*0.8;

   amnt2= 160 + ((unit-200)*0.9);

   amnt3=250 + ((unit - 300)*1);


  bill = (unit<=200)?(amnt1):((unit>200 && unit<=300)?(amnt2): (amnt3));

  printf("The Value : %.2f  \t  ",bill);

    tbill = bill + 100;


    ubill =(tbill>=400)?((tbill*0.15)+tbill):(tbill);

    printf("Final Bill : %.2f tk \n",ubill);

    return 0;

}


Comments