project telephone billing system

Upload: aishwaryagupta

Post on 05-Jan-2016

98 views

Category:

Documents


11 download

DESCRIPTION

More Details

TRANSCRIPT

  • Appendix A 459

    Fig. A.4. The Typing Test Screen

    Major Project: Telephone Billing SystemA.2

    Learning ObjectivesAfter going through this project work, you will be able to:

    Understand how command-driven applications are developed. Apply the concept of classes and objects to real world situations. Learn how file I/O operations are performed in C++ .

    Telephone Billing SystemTelephone Billing System is a command-driven application that helps manage records of the customers and generate their telephone bills. Table A.2 lists the various coding elements of the application:

    Balagurusamy-OOP_App-A.indd 459Balagurusamy-OOP_App-A.indd 459 4/7/2011 12:23:11 PM4/7/2011 12:23:11 PM

  • 460 Object Oriented Programming with C++

    Table A.2. Key Coding ElementsElement Description

    account The account class realises the real world entity customer.obj An instantiation of the account class, obj is primarily used to work with the

    data at hand and update it in the backend database file.db.dat Is the primary database file which stores all the backend data for the applica-

    tion.add() This class method adds a new customer record.del() This class method deletes an existing customer record.modify() This class method modifies an existing customer record.display() This class method displays a list of existing customer records.display() This class method displays a list of existing customer records.generate() This class method generates the bill for an existing customer record.help() This class method displays help documentation to the user.numdigits() This method returns the number of digits contained in the passed integer value.mon() This method converts a months value from integer to string.

    Application CodeThe application code for Telephone Billing System application is given below. It contains comments at appropriate places to help understand the coding elements better.

    /*Header Files*/#include#include#include#include#include#include#include#include#include#include/*Defining account class*/class account{ char name[30]; char address[60]; long acc_no; long phone_no;

    public: void add(); void modify(); void del(); void display(); void generate();

    Telephone Billing System Application

    Balagurusamy-OOP_App-A.indd 460Balagurusamy-OOP_App-A.indd 460 4/7/2011 12:23:12 PM4/7/2011 12:23:12 PM

  • Appendix A 461

    void help();};

    account obj;

    int bil_ctr=1; //Counter variable for bill id

    /*Function for counting number of digits in an integer*/int numdigits(long n){ return(log10(n)+1);}/*Function for converting a months value from integer to string*/char *mon(int m){ switch(m) { case(1): return(Jan);

    case(2): return(Feb);

    case(3): return(Mar);

    case(4): return(Apr);

    case(5): return(May);

    case(6): return(Jun);

    case(7): return(Jul);

    case(8): return(Aug);

    case(9): return(Sep);

    case(10): return(Oct);

    case(11): return(Nov);

    case(12): return(Dec); }}

    Balagurusamy-OOP_App-A.indd 461Balagurusamy-OOP_App-A.indd 461 4/7/2011 12:23:12 PM4/7/2011 12:23:12 PM

  • 462 Object Oriented Programming with C++

    void main(){

    char ch1,ch2; while(1)

    { clrscr();

    gotoxy(30,5); cout

  • Appendix A 463

    gotoxy(30,8); cout

  • 464 Object Oriented Programming with C++

    gets(name); if(strlen(name)==0) { gotoxy(30,30); clreol(); cout

  • Appendix A 465

    while(1) { gotoxy(30,14); coutacc_no; if(numdigits(acc_no)!=5) { gotoxy(54,14); clreol(); gotoxy(30,30); clreol(); cout

  • 466 Object Oriented Programming with C++

    return; }

    fptr2.open(dbtemp.dat,ios::out); if(fptr2.fail()) { cout

  • Appendix A 467

    while(1) { gotoxy(20,18); cout

  • 468 Object Oriented Programming with C++

    else { gotoxy(30,30); clreol(); break; } } } } fptr2.write((char *)this,sizeof(obj)); }fptr1.close(); fptr2.close(); if(ch==N) return;

    if(flag==0) { gotoxy(20,5); clreol(); cout

  • Appendix A 469

    getch(); return; }

    fptr2.open(dbtemp.dat,ios::out); if(fptr2.fail()) { cout

  • 470 Object Oriented Programming with C++

    else { gotoxy(20,12); cout

  • Appendix A 471

    cout

  • 472 Object Oriented Programming with C++

    { cout

  • Appendix A 473

    bill=lcalls*0.25+tcalls*1.00+icalls*5.00;

    gotoxy(2,32); cout

  • 474 Object Oriented Programming with C++

    gotoxy(1,2); cout

  • Appendix A 475

    gotoxy(40,22); cout

  • 476 Object Oriented Programming with C++

    Fig. A.6. The Manage Customer Records Screen

    Fig. A.7. The Display Screen

    Balagurusamy-OOP_App-A.indd 476Balagurusamy-OOP_App-A.indd 476 4/7/2011 12:23:12 PM4/7/2011 12:23:12 PM

  • Appendix A 477

    Fig. A.8. Adding Customer Records

    Fig. A.9. Modifying Customer Records

    Balagurusamy-OOP_App-A.indd 477Balagurusamy-OOP_App-A.indd 477 4/7/2011 12:23:13 PM4/7/2011 12:23:13 PM

  • 478 Object Oriented Programming with C++

    Fig. A.10. Deleting Customer Records

    Fig. A.11. Generating Telephone Bill

    Balagurusamy-OOP_App-A.indd 478Balagurusamy-OOP_App-A.indd 478 4/7/2011 12:23:13 PM4/7/2011 12:23:13 PM

  • Appendix A 479

    Fig. A.12. The Help Screen

    Balagurusamy-OOP_App-A.indd 479Balagurusamy-OOP_App-A.indd 479 4/7/2011 12:23:13 PM4/7/2011 12:23:13 PM