Write a program in C to Input meter number, current reading, previous reading and consumer type (residential (r) or Commercial (c) ). Calculate billing amount as per criteria given below.
Residential |
Commercial |
||
Units |
Rate |
Units |
Rate |
0-100 |
3.5 Rs./unit |
0-500 |
7.00 Rs./unit |
Above 100 |
5.5 Rs./unit |
Above 500 |
11.50 Rs./unit |
Display the bill showing meter number, current reading, previous reading, units consumed , tye and billing amount.
source file name: ElectricBill.C
#include <stdio.h>
int main()
{
long cono,cr,pr,unit;
float amt;
char type;
// clrscr();
printf("\n enter Meter no, type ( r or c) \n");
scanf("%ld %c",&cono,&type);
printf("\n enter current and Previous reading ");
scanf("%ld%ld",&cr,&pr);
unit=cr-pr;
if(type=='r')
{
if(unit<=100)
amt=unit*3.5;
else
amt=unit*5.5;
}
if(type=='c')
{
if(unit<=500)
amt=unit*7.00;
else
amt=unit*11.50;
}
printf(" \n Meter no: %ld ",cono);
printf(" \n Current reading: %ld Previous reading:%ld",cr,pr);
printf(" \n Consumed units: %ld Type:%c ",unit,type);
printf(" \n Bill Amount: %f ",amt);
//getch();
return 0;
}
output:
Input 1 for Residential consumer type
0 Comments
Post a Comment