2 Replies - 10247 Views - Last Post: 27 May 2011 - 02:43 AM Rate Topic: -----

#1 gaurav007  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-May 11

electricity bill code in c++

Posted 27 May 2011 - 02:17 AM

I am having problem in executing my code in c++,while compiling it is showing errors such as must use c++ for the type FSTREAM.H,unable to open include file 'IOSTREAM.H',DOS.H,STDLIB.H
#include<dos.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<fstream.h>
#include<iostream.h>
#include<graphics.h>
struct bil
   {
       int mtrno,prevrea,currea;
       char name[15],add[30];
    }s;

class bill
{
   int metno,dd,mm,yyyy,currea,prevrea,unit;
   char name[15],add[30],ch;
   float amnt,tot,sertax,ltot,late;

   public:
  void insert();
  void show();
  void search();
  void modify();
  void makebill();
  void display();
};

void bill::insert()
{
    fstream f;
    clrscr();
    setbkcolor(BROWN);
    f.open(“std.txt”,ios::out|ios::app|ios::binary);

    if(!f)
    {
      cout<<”\n File not found”;
      s.mtrno=1;
      exit(0);
    }
 cout<<”\n Enter name    :=”;
 cin>>s.name;
 cout<<”\n Enter address :=”;
 cin>>s.add;
 prevrea=0;
 currea=0;
 s.mtrno=s.mtrno+1;

// cout<<”\n Enter meter no:=”;
 //cin>>s.mtrno;
 f.write((char*)&s,sizeof(s));
 f.close();
}

void bill::show()
{
    fstream f;
    clrscr();
       setbkcolor(BROWN);
    f.open(“std.txt”,ios::in|ios::binary|ios::app);
    // setbkcolor(BROWN);
    if(!f)
    {
     cout<<”\n File not found”;
     exit(0);
    }
    else
    {
  cout<<”\n bill record:=”;
  cout<<”\n———————————————————————————”;
  while(f.read((char*)&s,sizeof(s)))
  {
  cout<<”\n\t”<<s.mtrno<<”\t”<<s.name<<”\t”<<s.add;
  cout<<”\n———————————————————————————”;
  }
 getch();

    }

 f.close();
}

void bill::search()
{
    fstream f;
    clrscr();
    int mno;
       setbkcolor(BROWN);
    f.open(“std.txt”,ios::in|ios::binary);
    //setbkcolor(BROWN);
      if(!f)
      {
 cout<<”\n File not found”;
 exit(0);
      }
      cout<<”\nEnter meter no. to search:=”;
      cin>>mno;
      while( f.read((char*)&s,sizeof(s)))
      {
  if(mno==s.mtrno)
  {
    cout<<”\n record found”;
    cout<<”\n——————————————–” ;
    cout<<”\nName      :”<<s.name;
    cout<<”\nAddress   :”<<s.add;
    cout<<”\nMeter No   :”<<s.mtrno;
    cout<<”\n——————————————–”;
  }
      }
     getch();
    f.close();
}
void bill::modify()
{
    fstream f;
    clrscr();
    int mno,count;
    long int pos;
    setbkcolor(BROWN);
    f.open(“std.txt”,ios::out|ios::in|ios::binary);

    if(!f)
     {
       cout<<”\n File not found”;
       exit(0);
      }
      cout<<”\n Enter meter no to be modified:=”;
      cin>>mno;
      count=0;
      while( f.read((char*)&s,sizeof(s)))
      {
      if(mno==s.mtrno)
        {
    cout<<”\n old record”;
    //cout<<”\n\t”<<s.name<<”\t”<<s.add<<”\t”<<s.mtrno;
    cout<<”\n——————————————–” ;
    cout<<”\nName      :”<<s.name;
    cout<<”\nAddress   :”<<s.add;
    cout<<”\nMeter No   :”<<s.mtrno;
    cout<<”\n***************************************”;

    cout<<”\n\n\n Enter New Record”;
    cout<<”\n———————————————”;
    cout<<”\n Enter name     :=”;
    cin>>s.name;
    cout<<”\n Enter address  :=”;
    cin>>s.add;
    cout<<”\n———————————————-”;

    pos=count*sizeof(s);
    f.seekp(pos,ios::beg);
    f.write((char*)&s,sizeof(s));
  }
       count++;
       f.clear();
 }
    f.close();
 }

void bill::makebill()
{
 clrscr();
 int x,y;
 detectgraph(&x,&y);
 initgraph(&x,&y, ” “);
 setbkcolor(YELLOW);
 setcolor(RED);

 fstream f;
 int mno;
 f.open(“std.txt”,ios::in|ios::binary);
 if(!f)
 {
   cout<<”\n File not found”;
   exit(0);
 }
  cout<<”\nEnter meter no to make bill:=”;
  cin>>mno;
 while( f.read((char*)&s,sizeof(s)))
 {
  if(mno==s.mtrno)
  {
   cout<<”\n*************UTTARAKHAND ELECTRICITY BOARD******************\n “;
   cout<<”\nName              :”<<s.name;
   cout<<”\nAddress           :”<<s.add  ;
   cout<<”\nMeter No          :”<<s.mtrno;
   cout<<”\n*************************************************************\n”;
   prevrea=currea;
   cout<<”previous reading    :”<<prevrea;
   cout<<”\ncurrent reading     :”;
   cin>>currea;
   cout<<”Enter date of bill(dd/mm/yyyy):” ;
   cin>>dd>>mm>>yyyy;

   unit=currea-prevrea;
   if(unit>300)
    amnt=unit*(3.50);

   else if(unit>200 && unit<=300)
    amnt=unit*3.00 ;

   else if(unit>100 && unit<=200)
    amnt=unit*(2.50);

   else
    amnt=unit*2.00;
   sertax=amnt*0.11;
   tot=sertax+amnt;
   late=tot*0.05;
   ltot=tot+late;
  if(mm<12)
  {
   mm=mm+1;
  }
  else
  {
   mm=01;
   yyyy=yyyy+1;
  }
       }
 }
f.write((char*)&s,sizeof(s));
f.close();
}
void bill::display()
 {
 clrscr();
 fstream f;
 int mno;
    setbkcolor(BROWN);
 f.open(“std.txt”,ios::in|ios::binary);
 if(!f)
 {
   cout<<”\n File not found”;
   exit(0);
 }
  cout<<”\nEnter meter no to display bill:=”;
  cin>>mno;
 while( f.read((char*)&s,sizeof(s)))
 {
  if(mno==s.mtrno)
  {
   cout<<”\n**************************************************************\n”;
   cout<<”\n* total unit is               :”<<unit;
   cout<<”\n*————————————————————*\n”;
   cout<<”\n* amount is                   :”<<amnt;
   cout<<”\n*————————————————————*\n”;
   cout<<”\n* service tax amount is       :”<<sertax;
   cout<<”\n*————————————————————*\n”;
   cout<<”\n* total amount is             :”<<tot;
   cout<<”\n*————————————————————*\n”;
   cout<<”\n* Last date to be paid        :”<<dd<<”-”<<mm<<”-”<<yyyy;
   cout<<”\n*————————————————————*\n”;
   cout<<”\n* Total amount after this date:”<<ltot;
   cout<<”\n**************************************************************\n”;

   getch();
  }
  }

    f.close();
}
pass()
{
 clrscr();
 int gd=DETECT,gm;
 initgraph(&gd,&gm,” “);
 setbkcolor(BROWN);
 int valid=0,retry=1;
 char  pass[4]=”",password[]=”ebill”;
 setbkcolor(45);

 cout<<”\n\n\t\t\t ************************************”;
 cout<<”\n\t\t\t  *         ELECTRICITY BILL         *”;
 cout<<”\n\t\t\t  ************************************”;
 do
 {
  gotoxy(32,14);  cout<<”Enter The Password: “;
  int i=0, p=0;
  while(p!=13)
  {
   p=getch();
   if(p!=13)
   {
    pass[i]=p;
    i++;
    cout<<”*”;
   }
  }

  if(strcmp(pass,password)==0)
  {  valid=1; break;}
  else
  {
   clrscr();
   // gotoxy(30,16); cout<<”Incorrect Password!”;
   valid=0;
   retry+=1;
  }
  //else
  //valid=1;
  }while(!valid || retry<=3);

  if(retry>3)
  {
  gotoxy(28,16);  cout<<”Maximum 3 try only! Bye!”;
  getch();
  exit(0);
  }
  else
 {
  //clrscr();
  setbkcolor(BROWN);
  setcolor(6);
  gotoxy(32,16);
  cout<<”Access approved!”;
   getch();
  clrscr();
  }
  return 0;
}

/*for graphics*/
graph()
{
 int r,c;
 clrscr();
   //  setbkcolor(BLUE);
   //       settextstyle(4, 1, 5);
 cout<<endl;
 cout<<endl;
 cout<<” U “;
 delay(300);
 cout<<”T “;
 delay(300);
 cout<<”T “;
 delay(300);
 cout<<”A “;
 delay(300);
 cout<<”R “;
 delay(300);
 cout<<”A “;
 delay(300);
 cout<<”K “;
 delay(300);
 cout<<”H “;
 delay(300);
 cout<<”A “;
 delay(300);
 cout<<”N “;
 delay(300);
 cout<<”D “;
 delay(300);
 cout<<”S “;
 delay(300);
 cout<<”T “;
 delay(300);
 cout<<”A “;
 delay(300);
 cout<<”T “;
 delay(300);
 cout<<”E    “;
 delay(300);
 cout<<”E “;
 delay(300);
 cout<<”L “;
 delay(300);
 cout<<”E “;
 delay(300);
 cout<<”C “;
 delay(300);
 cout<<”T “;
 delay(300);
 cout<<”R “;
 delay(300);
 cout<<”I “;
 delay(300);
 cout<<”C “;
 delay(300);
 cout<<”I “;
 delay(300);
 cout<<”T “;
 delay(300);
 cout<<”Y   “;
 delay(300);
 cout<<”B “;
 delay(300);
 cout<<”O “;
 delay(300);
 cout<<”A “;
 delay(300);
 cout<<”R “;
 delay(300);
 cout<<”D “;
 delay(300);
 cout<<”   “;
 delay(1400);
 cout<<” \n\n\n\n\n\n\n\n\n\n\n\n\n  PRESS ANY KEY …….. “;
 return 0;
}

  graphics()
  {
 int x,y;
 clrscr();
 detectgraph(&x,&y);
 initgraph(&x,&y,”");
 int i,p,q;
 for(i=480;i>=0;i–)
     {
       setcolor(5);
       line(0,i,i,0);
       line(getmaxx(),i,getmaxx()-480+i,getmaxy());
       delay(2);
     }
 for(i=170;i>=0;i–)
     {
       line(i,getmaxy(),480+i,0);
       delay(2);
     }

 setcolor(14);
 settextstyle(7,0,4);
 outtextxy(125,25,” ELECTRICTY BILL”);
 outtextxy(250,60,”GENERATION”);
 settextstyle(4,0,2);
 outtextxy(0,110,”———————-!!:*:!!———————-”);
 settextstyle(1,0,2);
 setcolor(10);
 outtextxy(230,340,”UNDER GUIDANCE OF “);
 setcolor(7);
 outtextxy(260,390,”PROF S.D.RANE “);
 setcolor(2);
 //outtextxy(100,390,”  _______  ______    “);
 //outtextxy(120,400,”         ..      “);
 rectangle(0,0,getmaxx(),getmaxy());
 rectangle(5,5,getmaxx()-5,getmaxy()-5);

 for(i=0 ;i<65 ;i++)
     {
       for(int j=0 ;j<1 ;j++)
       {
  setcolor(i+4);
  settextstyle(7,0,30);
  outtextxy(3,19,” *——* “);
  delay(5);
  j=1;
       }
       setcolor(i);
       settextstyle(7,0,4);
       outtextxy(80,150,”  PROJECT”);
       delay(10);
       setcolor(i);
       outtextxy(280,150,”DEVELOPED”);
       delay(10);
       setcolor(i);
       outtextxy(440,150,”    BY   “);
       delay(10);
       for(j=0 ;j<1 ;j++)
       {
  setcolor(i-2);
  settextstyle(7,0,42);
  outtextxy(3,19,” *——* “);
  delay(5);
  j=0;
       }
     }
     for(p=100,q=570;p<=570,q>=100;p++,q–)
       {
  setcolor(BLACK);
  circle(p,195,2);
  circle(q,330,2);
  delay(5);
       }
       setcolor(67);
       settextstyle(1,0,2);
       outtextxy(170,200,”MANISH BAHETI”);
       outtextxy(170,230,”BHUSHAN TARE”);
       outtextxy(170,260,”PRASAD KULKARNI”);
       outtextxy(170,290,”SHIVPARASAD MURGUDE”);

  delay(5000);
 for(i=480;i>=0;i–)
     {
       setcolor(19);
       line(i,0,0,i);
       line(getmaxx(),i,getmaxx()-480+i,getmaxy());
       delay(2);
     }
 for(i=170;i>=0;i–)
     {
       line(i,getmaxy(),480+i,0);
       delay(2);
     }
     }
  void main()
 {
 clrscr();
 int d;
 char ch;
 bill s1;
 graph();
 graphics();
 pass();

 do
 {
  clrscr();
  do
  {
        setbkcolor(BROWN);
    //    textcolor(RED);
        settextstyle(1,0,2);
        outtextxy(170,200,”1.INSERT”);
        outtextxy(170,225,”2.SHOW”);
        outtextxy(170,250,”3.SEARCH”);
        outtextxy(170,275,”4.MODIFY”);
        outtextxy(170,300,”5.MAKE BILL”);
        outtextxy(170,325,”6.DISLAYBILL”);
        outtextxy(170,350,”7.EXIT”);
        gotoxy(32,23);

 /*cout<<”\n\t       @   @   @    @  @   @       @   @ @@@@@ @   @ @   @       “; cout<<”\n\t=====  @@ @@  @ @   @  @@  @       @@ @@ @     @@  @ @   @  =====”;
 cout<<”\n\t=====  @ @ @ @@@@@  @  @ @ @       @ @ @ @@@@  @ @ @ @   @  =====”;
 cout<<”\n\t=====  @   @ @   @  @  @  @@       @   @ @     @  @@ @   @  =====”;
 cout<<”\n\t       @   @ @   @  @  @   @       @   @ @@@@@ @   @  @@@\n\n\n\n”;
 cout<<”\n\t\t+———————————————–+”;
 cout<<”\n\t\t|                                               |”;
 cout<<”\n\t\t|  1. Enter new record                          |”;
 cout<<”\n\t\t|                                               |”;
 cout<<”\n\t\t|  2. List of customers                         |”;
 cout<<”\n\t\t|                                               |”;
 cout<<”\n\t\t|  3. Search                |”;
 cout<<”\n\t\t|                                               |”;
 cout<<”\n\t\t|  4. Modify                                    |”;
 cout<<”\n\t\t|                                               |”;
 cout<<”\n\t\t|  5.Display bill                               |”;
 cout<<”\n\t\t|                                               |”;
 cout<<”\n\t\t|  6.exit                                       |”;
 cout<<”\n\t\t|                                               |”;
 cout<<”\n\t\t+———————————————–+”;
     */
 cout<<”\n\t\nEnter your choice:”;
 cin>>d;

       switch(d)
       {

   case 1:s1.insert();
  break;
   case 2:s1.show();
  break;
   case 3:s1.search();
  break;
   case 4:s1.modify();
  break;
   case 5:s1.makebill();
  break;
   case 6:s1.display();
  break;
   case 7:
  exit(0);
   }

       }while(ch==’y'||ch==’Y');

     }   while(d<8);
       getch();
  }



Is This A Good Question/Topic? 0
  • +

Replies To: electricity bill code in c++

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,515
  • Joined: 23-August 08

Re: electricity bill code in c++

Posted 27 May 2011 - 02:31 AM

Because you copied and pasted the code which was written by someone using an ancient compiler.

Maybe that's a hint you should do YOUR OWN homework, rather than stealing someone else's? Or maybe you just need to write your phone number on the assignment.
Was This Post Helpful? 1
  • +
  • -

#3 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1675
  • View blog
  • Posts: 3,171
  • Joined: 30-May 10

Re: electricity bill code in c++

Posted 27 May 2011 - 02:43 AM

Don't forget to fix the names before you palm this off as your own work.
453	       outtextxy(80,150,”  PROJECT”);
...
456	       outtextxy(280,150,”DEVELOPED”);
...
459	       outtextxy(440,150,”    BY   “);
...
479	       outtextxy(170,200,”MANISH BAHETI”);
480	       outtextxy(170,230,”BHUSHAN TARE”);
481	       outtextxy(170,260,”PRASAD KULKARNI”);
482	       outtextxy(170,290,”SHIVPARASAD MURGUDE”);


Was This Post Helpful? 2
  • +
  • -

Page 1 of 1