Jan 22, 2018, 09:22 PM

## News:

IT Acumens - A Web Designing Company

## Program to Generate the Electricity Bill

Started by thiruvasagamani, Sep 22, 2008, 04:22 PM

Go Down

#### thiruvasagamani

##### Sep 22, 2008, 04:22 PM
Generate electricity bill ,inputs meter number,customer name,prevous reading,present reading,type c1 for resident,type 2 for commercial,units = pres- prev readings,surcharge 10/-

i. if unit is first 100(0-99) cost is 3/- per unit
ii. next 100(100-199) units cost is 3.50/- per unit
iii. next 200 (200-399)units cost is 4/- per unit
iv. next 300 (400-699) units cost is 4.50 per unit
v. above 700 units cost is 5/- per unit

Program :

Code: [Select]
`#include <stdio.h>#include <conio.h>main(){int mno,type,units,k;long prev,pres;char cname[20];float cost;clrscr();printf("enter meter number \n");scanf("%d",&mno);printf("enter customer name\n");fflush(stdin);gets(cname);// flushes the \n in cname before storing a string in cnameprintf("enetr prev & pres reading\n");scanf(" %ld%ld",&prev,&pres);printf("enter 1- residential, 2- commercial \n");scanf("%d",&type);units= abs(pres - prev);switch(type){case 1 :// residential{k = units / 100;switch(k){case 0 :{cost = units * 3.00;// units beween 0-99break;//goes out inner switch}case 1 :{cost= 100 * 3.00 + (units-100)*3.5;break;//units between 100-199}case 2 :case 3 :{cost=100*3.00 + 100*3.50+(units-200)*4.00;break;//units between 200-399}case 4 :case 5 :case 6 :{cost =100*3.00+100*3.50+200*4.00+(units-400)*4.50;break;//units between 400to700}default :{cost=100*3.00+100*3.50+200*4.00+300*4.50+(units-700)*5.00break;//units above 700,control goes out from inner switch}//end of default} //end of inner switchbreak;//residential case 1 ends after this control goes out from outer switch}case 2 :{cost = units *5.00;break;//control goes out from outer switch}}//end of outer switchprintf("bill amount = %.2f",cost+10);getch();}`
Thiruvasakamani Karnan

Go Up

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview
IT Acumens | GinGly :: SMS Backup | Acumen :: Discussion Board | AshokPillar :: Hosting | CineBuzz :: Latest Cinema News | My Kids Diary :: Capture your kids magical moment