Program To Accept No. Of Electrical Units Consumed And Then Display The Bill Payable
/* PROGRAM TO ACCEPT NO. OF ELECTRICAL UNITS CONSUMED AND THEN DISPLAY THE BILL PAYABLE USING EITHER TELESCOPIC OR NON-TELESCOPIC METHOD BASED ON THE USERS CHOICE.THE RATES ARE AS GIVEN BELOW UNITS RATE ----------- ------------- <= 100 Rs. 1.50 PER UNIT 101 -> 300 Rs. 2.50 PER UNIT 301 -> 500 Rs. 3.50 PER UNIT > 500 Rs. 4.50 PER UNIT */ #include
#include
void main() { int u; float b; char ch; clrscr(); printf("\nenter number of units consumed\n\n"); scanf("%d",&u); printf("\nCompute the bill using (n)on-telescopic or (t)elescopic method: \n\n"); fflush(stdin); ch=getchar(); if(ch=='n') { if(u<=100) b = u*1.50; else if(u<=300) b = u*2.50; else if(u<=500) b = u*3.50; else b = u*4.50; printf("\nelectricity bill payable in non-telescopic method = %f",b); } else if(ch=='t') { if(u<=100) b = u*1.50; else if(u<=300) b = (100*1.50)+((u-100)*2.50); else if(u<=500) b = (100*1.50*1)+(200*2.50)+((u-300)*3.50); else b = (100*1.50)+(200*2.50)+(200*3.50)+((u-500)*4.50); printf("\nelectricity bill payable in telescopic method = %f",b); } else printf("\n invailed option\n"); getch(); }
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/