[go: up one dir, main page]

0% found this document useful (0 votes)
31 views62 pages

Fast Food Billing: Training Report ON

Download as doc, pdf, or txt
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 62

TRAINING REPORT ON

FAST FOOD BILLING


Submitted in partial fulfillment of the requirements for the award of the degree of BACHELOR OF TECHNOLOGY IN COMPUTER SCIENCE AND ENGINEERING FROM KURUKSHETRA UNIVERSITY, KURUKSHETRA Under the guidance of Mr. AMRITPAL SINGH VERSION TECHNOLOGIES, PANIPAT Submitted by MAYANK GARG 2207251 CSE-2

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING SWAMI DEVI DYAL INSTITUT OF ENGINEERING AND TECHNOLOGY, BARWALA PANCHKULA

Index
Acknowledgement. Certificate. Requirement for running the project. System Design. Feasibility Study. Information Gathering. Information Gathering Tools. Logical Design. Physical Design. Input Design. Output Design. Conclusions. Utility Of Project. Future Scope Of The Project. Bibliograbhy. Coding. Introduction of C + +

PREFACE
In our B.Tech(Computer Science) course it is obligatory on part of every student to prepare a Project Report in partial fulfillment requirement of the degree course . Students by preparing the project , experience the actual working situation and have a deep view of Computer Applications in practical work . I have made my project on the Fast Food Billing. What I have done on this project , a report of that is being presented in this project report.

MAYANK GARG Roll No. : 2207251 B.Tech(Computer Engg.) 3rd Year ( 5th Semester)

ACKNOWLEDGEMENT
I feel immense pleasure in presenting valuable possession of my COURSE CO-ORDINATION to Kurukshetra University, Kurukshetra . I can not find words suitable enough to express my indebtness . Im grateful to Mr. AMRITPAL SINGH, PANIPAT valuable guidance and moral support during the course of project , without which it would have been difficult for me to complete this project . I am thankful to my parents for their concern to my problem and encouraging me .

MAYANK GARG Roll No. :2107248 B.Tech(Computer Engg.) 3rd Year (5th Semester)

REQUIREMENTS FOR RUNNING THE PROJECT

SOFTWARE MINIMUM WINDOW(WINDOWS 95), C++ COMPILER

RAM-

MINIMUM OF 8 MB RAM

DISPLAY TYPE MONO, COLORED PREFERRED

DISKSPACE 5- 10 MB OF DISKSPACE

PRINTER ANY

SYSTEM DESIGN

So far in our project , User requirements have been identified Information has been gathered to verify the problem and evaluate the existing system . The features and reasons behind the new (proposed) system make sense .

At this point , we began with the design phase of the system. .

System design is a solution , a how to approach to the creation of new system . It translates system requirements into ways of operationalizing them . It is a translation from a user oriented document to a document oriented programmers . For that , it provides the understanding and procedural details necessary for the implementation .

FEASIBILITY STUDY
While developing a computer system. The main objective of feasibility Study is to test the technical, social and economic feasibility. We can do this investigation the existing system in the area creating idea about a new system. The proposed system must be tested for technical view point and if it is technically feasible then we must test for economic feasibility.

ASSESSING TECHNICAL FEASIBILITY The includes requirement in terms of inputs, outputs, files, programs,

procedures and tools, for storing and handling data. It includes two main considerations. 1) SOFTWARE REQUIREMENT In order to execute my system programs. We need C++ compiler .

2) HARDWARE REQUIREMENT Hardware requirement is PC-XT, PC-AT.

ASSESSING ECONOMIC FEASIBILITY A proposed of developing system must be justified by cost and benefit criteria so that effort in concentrated on projects which will give the best return at the earliest opportunity. The cost benefit analysis is generally used as a basis for assessing the economic feasibility. The factors for evaluation are as follows: -

(i)
(ii) (iii)

Cost of operation of the existing and proposed system. Cost of development of the proposed system. Value of benefits of the proposed system. In assessing economic feasibility our efforts should be to increase profit and reduce expenditure and improve the quality of a service or goods which can provide increased profits. The computerization of billing System can be considered as search of economic within expensive technology which avoid lot of paper work is done manually which is very costly.

ASSESSING SOCIAL FEASIBILITY The various affected people must be considered. Its impression on billing, menu shown, order, purchasing, editing menu, cost of the items considered. The proposed package enable easy ordering , total billing and minimization of errors and efficiency through quick transactions. SYSTEM ANALYSIS DEFINITION OF SYSTEM System Development consists of two major steps, namely (I) (II) System Analysis Design. should be

This process is adopted when management of system development, Personnel decide that the particular system needs improvement .The system development life cycle is the set of activities, carried out by the analyst, designers and users to develop and implement a system.

SYSTEM DEVELOPMENT LIFE CYCLE The systems that are present in the nature follow a common life cycle pattern. For example, consider the raining system. Initially the rainfalls into the river, river flows in to sea, the seawater evaporates to form vapor, the vapour forms cloud which again bring rain. Similarly consider a man made system initially, a system is analysis, designed and made operational by the efforts of system analysis. After successful operation or a number of users, the System becomes less and less effective by the modifications incorporated in to the system due to the change in the environment. For example, an industrial payroll system becomes less affective after a new wage agreement between the management and staff. This has to be incorporated in to the system by minor modification. This type of minor modifications accumulated over a period of time will make the system less effective to further less effective to further modifications. Hence, after a few years of operation sit may be necessary to change the fundamental concepts of the existing system. The existing system has not be analyzed and to make it more efficient. Sometimes a complete redesign may be necessary. After this, the modified of completely redesigned system will be implemented and become operational. The new system will be in operation for a number or years till it becomes obsolete and the cycle starts against can also be seen that at any stage in the cycle there is an operational system. Which is subjected to continuous modification, review &maintenance.

SYSTEM LIFE CYCLE ACTIVITIES

The different activities that constitute the life cycle of system must be logical, relational, valid and relevant to the system .It should be noted that the activities are highly related usually inseparable. Many times even the order of steps will be difficult to determine. In general the six activities that from the life cycle of system are given below: (i) Selection and identification of the system to be studied. (ii) Preliminary study. (iii) Defining the System. (iv) Design and Development of the system. (v) Implementing the System. (vi) System maintenance and review.

INFORMATION GATHERING
Information gathering is an art and science . The approach and manner in which is gathered requires sensitivity , common sense and a knowledge of what and when to gather .

The kind of information we needed for our system was about the user staff .

Information about the items : This includes the items that are offerred by the fast food. Information about the price of items: This includes the price of each item. Information about the work flow: Work Flow focuses on what happens to the data through various points in a system. This can be shown by a data flow diagram or a system flowcharts. A flowchart represents the information generated at each processing point in the system and the direction it takes from source to destination. A system flowchart describe the physical system . The information available from such charts explains the procedure used for performing task and work schedules.

Information Gathering Tool Used


ON-SITE OBSERVATIONS : On - site observation is the process of recognizing and noting people , objects , occurrences to obtain the information the organization or the present system . This also includes full participation of the user staff also . The major objective is to get as close as possible to the real system being studied . For this , it is important to have the knowledge of the general makeup and activities of the system .

However , in our case , through the on - site observations , the answers to the following questions were served :

What kind of system is the present system ? Ans. : manual

Who handles the system ? Ans. : The Owner in the Shop.

How does he make all transcations ? Ans. : By hand

How does he make the bill? Ans. : By simply entering the order and then select the total bill option in the main menu.

Logical Design
Our logical design covers the following : 1. Reviewed the current physical system . 2. Prepared output specifications , i.e. , it determines the format and contents of the output functions . 3. Prepared input specifications , i.e. , it determines the format , contents and most of the input functions . It includes the flow of document from input data source to actual input location . 4. Preparation of edit and security specifications . This includes the rules for edit corrections and control s that ensure processing . 5. Specifies the implementation plan .

Physical Design
Following the logical design , is the physical design .

The physical design produced the working system by defining the design specification that told us (as a programmer) exactly what the proposed system must do . In turn , we wrote the necessary program that : Accepts input from the user . Performs the necessary calculations through the existing files . Produces (displays) the report on the screen . Maintains and updates the data base at all times .

The physical design of the fast food billing is a program written in C++ . The program has been designed in such a way that it displays menus that specify how to do the desired operation .

INPUT DESIGN
Input design is the process of converting user originated inputs to a computer based format. In system design phase , the expanded data flow diagrams identify logical data flows , data stores, sources and destinations. Input data are collected and organized into groups of similar data using an appropriate input media .

Input Data : The goal here is to make data entry as easy , logical , and free from errors as possible .

The Input Device used here is the Keyboard .

The Method of Data Capture and Entry is Manual Data Entry. Manual data entry makes use of a processor that accepts commands and data from the operator through the keyboard . The input received is analyzed by the processor . It is then accepted or rejected , or further input is requested . The request for the input is in the form of a message displayed on the screen . The approach used for entering the data is the Menu Approach . The menu is the selection list that simplifies computer data access or entry . The Options are displayed Graphically to the user. The menu is the selection list that simplifies computer data access or entry . The options are displayed with their corresponding numbers and the user chooses from this list what to enter in the ENTER YOUR CHOICE field .

OUTPUT DESIGN
Computer output is the most important and direct source of information to the user . The major form of output of our program is displayed on the CRT screen . The output can be obtain as a hard copy from the printer . Printouts should be designed around the output requirement of the user. The Output devices to consider depend on factors such as compatibility of the device with the system, response, time, requirement, expected print quality and no. of copies needed.

The following media devices are available for providing computer based output:

MICR readers Line, Matirx and daisy wheel printers Computer output microfilm(COM) CRT Screen display Graph Plotters

CONCLUSIONS
ADVANTAGES OF THE PROPOSED SYSTEM
The benefits that are contributed by the proposed system computer based system are as follows :

1.

Provides Maintenance of Accounts.

2. Make access to data easy for users . 3. Provides response to the users request for data and information . 4. Helps to Calculate the total bill in a database immediately . available

5.

Since Everything is done using computers , a lot of human effort is saved .

6. Easy to Maintain . 7. Time saving, portable.

DISADVANTAGES OF THE PROPOSED SYSTEM


The only disadvantage of the system would be that this system would require evaluation after implementation . We would have to evaluate the system after a certain period to find out how well the system is meeting the objectives originally set forth . This would lead to wastage of time , money and require some improvements included

UTILITY OF THE PROJECT


Thus the use of the software on the net makes it best suitable for all the Fast Food Shops, Resorts,Restaurants etc. Owner is no longer required to do paper work which leads to the mistake.With the use of this project he/she take the order on the computer and total bill is calculated by the project itself. He / she is just required to select the facts and enter the desired options . On the whole it liberates the user from keeping lengthy manual records . In a nutshell , it abates the work load of an organization .

FUTURE SCOPE OF THE PROJECT


This project is aimed to improve organizational effectiveness. It has a far reaching impact on the entire organization . The implementation of the project will affect more the established methods and procedures . The system can enhance the productivity by : 1 2 3 4 5 Optimizing the output of the system . Helping in routine work functions Increasing accuracy Reducing normal errors Effective management of time and resources

Bibliography
The following were referenced to prepare the project :

1. Complete Reference, C++ 2. Object Oriented Programming with C++ by E.Balaguruswamy 3. Object Oriented Programming with C++ by Robert Lafore

CODING

//********************************************************** // PROJECT FAST-FOOD AUTOMATION //********************************************************** //********************************************************** // INCLUDED HEADER FILES //********************************************************** #include <iostream.h> #include <fstream.h> #include <process.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <conio.h> #include <dos.h> //********************************************************** // CLASS NAME : menu // DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS //********************************************************** class menu { public : void main_menu(void) ; private : void box(void) ; void edit_menu(void) ; }; //********************************************************** // CLASS NAME : food // DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS // RELATED TO FOOD ITEMS //********************************************************** class food { public : void add_item(void) ; void delete_item(void) ; void modify_item(void) ; void list_of_item(void) ; void purchase(void) ; private : int last_code(void) ;

void delete_record(int) ; void modify_record(int) ; void display_record(int) ; int item_found(int) ; int recordno(int) ; void sort(void) ; int itemcode ; char itemname[30] ; float itemcost, itemprice ; }; //********************************************************** // CLASS NAME : account // DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS // RELATED TO MAKING BILL //********************************************************** class account { public : void bill_list(void) ; void prepare_bill(int) ; int last_billno(void) ; void add_bill(int, int t_itemcode, char *t_itemname, float t_qty, float t_cost, float t_price) ; private : int code, billno, length ; int dd, mm, yy ; float cost, price, quantity ; char name[30] ; }; //********************************************************** // THIS FUNCTION DRAW BOX FOR THE MENUS //********************************************************** void menu :: box(void) { char c1=178, c2=177, c3=176 ; int k=1 ; gotoxy(1,2) ; for (int i=1; i<=1840; i++) { if (k == 1) cout <<c1 ; else if (k == 2)

cout <<c2 ; else if (k == 3) cout <<c3 ; k++ ; if (k == 4) k=1; } for (i=5; i<=21; i++) { gotoxy(21,i) ; cout <<" } } //********************************************************** // THIS FUNCTION CREATE MAIN MENU AND CALLS OTHER FUNCTIONS //********************************************************** void menu :: main_menu(void) { clrscr() ; char ch ; while (1) { clrscr() ; box() ; gotoxy(32,6) ; cout <<"F A S T F O O D" ; gotoxy(32,7) ; cout <<"~~~~~~~~~~~~~~~~" ; gotoxy(32,9) ; cout <<"1: PURCHASE" ; gotoxy(32,11) ; cout <<"2: SEE MENU" ; gotoxy(32,13) ; cout <<"3: EDIT" ; gotoxy(32,15) ; cout <<"4: TOTAL BILL" ; gotoxy(32,17) ; cout <<"0: QUIT" ; gotoxy(32,20) ; cout <<"Enter Choice : " ; ch = getche() ; if (ch == 27) return ; else if (ch == '1') {

";

food f ; f.purchase() ; } else if (ch == '2') { food f ; f.list_of_item() ; } else if (ch == '3') edit_menu() ; else if (ch == '4') { account a ; a.bill_list(); } else if (ch == '0') break ; } } //********************************************************** // THIS FUNCTION CREATE EDIT MENU AND CALLS OTHER FUNCTIONS //********************************************************** void menu :: edit_menu(void) { char ch ; while (1) { for (int i=5; i<=21; i++) { gotoxy(21,i) ; cout <<" } gotoxy(32,6) ; cout <<"E D I T M E N U" ; gotoxy(32,7) ; cout <<"~~~~~~~~~~~~~~~~" ; gotoxy(32,10) ; cout <<"1: ADD ITEM" ; gotoxy(32,12) ; cout <<"2: MODIFY ITEM" ; gotoxy(32,14) ; cout <<"3: DELETE ITEM" ; gotoxy(32,16) ;

";

cout <<"0: EXIT" ; gotoxy(32,19) ; cout <<"Enter Choice : " ; ch = getche() ; if (ch == 27) return ; else if (ch == '1') { food f ; f.add_item() ; break ; } else if (ch == '2') { food f ; f.modify_item() ; break ; } else if (ch == '3') { food f ; f.delete_item() ; break ; } else if (ch == '0') break ; } } //********************************************************** // THIS FUNCTION RETURNS THE CODE OF THE LAST RECORD IN THE // FOOD FILE (FOOD.DAT). //********************************************************** int food :: last_code(void) { fstream file ; file.open("FOOD.DAT", ios::in) ; file.seekg(0,ios::beg) ; int t=0 ; while (file.read((char *) this, sizeof(food))) t = itemcode ; file.close() ; return t ; }

//********************************************************** // THIS FUNCTION DISPLAY THE LIST OF THE FOOD ITEMS //********************************************************** void food :: list_of_item(void) { clrscr() ; fstream file ; file.open("FOOD.DAT", ios::in) ; file.seekg(0) ; int row = 6 , found = 0 , pageno = 1 ; gotoxy(30,2) ; cout <<"LIST OF ITEMS" ; gotoxy(29,3) ; cout <<"~~~~~~~~~~~~~~~" ; gotoxy(3,4) ; cout <<"ITEM CODE ITEM NAME ITEM COST ITEM PRICE" ; gotoxy(2,5) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; while (file.read((char *) this, sizeof(food))) { delay(20) ; found = 1 ; gotoxy(5,row) ; cout <<itemcode ; gotoxy(14,row) ; cout <<itemname ; gotoxy(37,row) ; cout <<itemcost ; gotoxy(51,row) ; cout <<itemprice ; if ( row == 22 ) { row = 5 ; gotoxy(66,1) ; cout <<"Page no. : " <<pageno ; gotoxy(66,2) ; cout <<"===============" ; pageno++ ; gotoxy(1,25) ; cout <<"Press any key to continue..." ; getche() ; clrscr() ; gotoxy(30,2) ; cout <<"LIST OF ITEMS" ; gotoxy(3,4) ;

cout <<"ITEM CODE ITEM NAME PRICE" ;

ITEM COST ITEM

gotoxy(2,5) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; } else row++ ; } if ( !found ) { gotoxy(5,10) ; cout <<"\7Records not found" ; } gotoxy(66,1) ; cout <<"Page no. : " <<pageno ; gotoxy(66,2) ; cout <<"===============" ; gotoxy(1,25) ; cout <<"Press any key to continue..." ; getche() ; file.close () ; } //********************************************************** // THIS FUNCTION ADD RECORDS IN THE FOOD FILE (FOOD.DAT) //********************************************************** void food :: add_item(void) { int tcode, valid ; char ch, t_itemcost[10], t_itemprice[10] ; tcode = last_code() ; tcode++ ; do { clrscr() ; gotoxy(71,2) ; cout <<"<0>=Exit" ; gotoxy(27,3) ; cout <<"ADD FOOD ITEM TO THE MENU" ; gotoxy(26,4) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; gotoxy(5,6) ; cout <<"Item Code : " <<tcode ; gotoxy(5,8) ; cout <<"Item Name : " ; gotoxy(5,10) ; cout <<"Item Cost : " ;

gotoxy(5,12) ; cout <<"Item Price : " ; do { valid = 1 ; gotoxy(1,8) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER ITEM NAME TO ADD IN THE MENU" ; gotoxy(5,8) ; cout <<"Item Name : " ; gets(itemname) ; strupr(itemname) ; if (itemname[0] == '0') return ; if ((strlen(itemname) < 1) || (strlen(itemname) > 20)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 1..20" ; getch() ; } } while (!valid) ; do { valid = 1 ; gotoxy(1,10) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER ITEM COST TO ADD IN THE MENU" ; gotoxy(5,10) ; cout <<"Item Cost : " ; gets(t_itemcost) ; itemcost = atof(t_itemcost) ; if (t_itemcost[0] == '0') return ; if (itemcost < 1 || itemcost > 800) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 1..800" ; getch() ; } } while (!valid) ; do { valid = 1 ; gotoxy(1,12) ; clreol() ;

gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER ITEM PRICE TO ADD IN THE MENU" ; gotoxy(5,12) ; cout <<"Item Price : " ; gets(t_itemprice) ; itemprice = atof(t_itemprice) ; if (t_itemprice[0] == '0') return ; if (itemprice < itemcost || itemprice > 1000) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = " <<itemcost <<"..1000" ; getch() ; } } while (!valid) ; do { gotoxy(1,15) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,15) ; cout <<"Do you want to save this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'Y') { itemcode = tcode ; fstream file ; file.open("FOOD.DAT", ios::out | ios::app ) ; file.write((char *) this, sizeof(food)) ; file.close() ; tcode++ ; } do { gotoxy(1,17) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,17) ; cout <<"Do you want to add more records (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ;

} while (ch != 'N' && ch != 'Y') ; } while (ch == 'Y') ; } //********************************************************** // THIS FUNCTION DISPLAY THE RECORD OF THE GIVEN CODE FROM // THE FOOD FILE (FOOD.DAT) //********************************************************** void food :: display_record(int tcode) { fstream file ; file.open("FOOD.DAT", ios::in) ; file.seekg(0,ios::beg) ; while (file.read((char *) this, sizeof(food))) { if (itemcode == tcode) { gotoxy(5,3) ; cout <<"Item Code : "<<itemcode ; gotoxy(5,4) ; cout <<"Item Name : "<<itemname ; gotoxy(5,5) ; cout <<"Item Cost : "<<itemcost ; gotoxy(5,6) ; cout <<"Item Price : "<<itemprice ; break ; } } file.close() ; } //********************************************************** // THIS FUNCTION RETURN THE VALUE 1 IF THE RECORD IS FOUND // FOR THE GIVEN CODE IN THE FOOD FILE (FOOD.DAT) //********************************************************** int food :: item_found(int tcode) { fstream file ; file.open("FOOD.DAT", ios::in) ; file.seekg(0,ios::beg) ; int found=0 ; while (file.read((char *) this, sizeof(food))) { if (itemcode == tcode) { found++ ;

break ; } } file.close() ; return found ; } //********************************************************** // THIS FUNCTION RETURN THE RECORD NO. OF THE GIVEN CODE IN // THE FOOD FILE (FOOD.DAT) //********************************************************** int food :: recordno(int tcode) { fstream file ; file.open("FOOD.DAT", ios::in) ; file.seekg(0,ios::beg) ; int found=0 ; while (file.read((char *) this, sizeof(food))) { found++ ; if (itemcode == tcode) break ; } file.close() ; return found ; } //********************************************************** // THIS FUNCTION DELETES THE RECORD FOR THE GIVEN CODE FROM // THE FOOD FILE (FOOD.DAT) //********************************************************** void food :: delete_record(int tcode) { fstream file ; file.open("FOOD.DAT", ios::in) ; fstream temp ; temp.open("temp.dat", ios::out) ; file.seekg(0,ios::beg) ; while ( !file.eof() ) { file.read((char *) this, sizeof(food)) ; if ( file.eof() ) break ; if ( itemcode != tcode ) temp.write((char *) this, sizeof(food)) ; }

file.close() ; temp.close() ; file.open("FOOD.DAT", ios::out) ; temp.open("temp.dat", ios::in) ; temp.seekg(0,ios::beg) ; while ( !temp.eof() ) { temp.read((char *) this, sizeof(food)) ; if ( temp.eof() ) break ; file.write((char *) this, sizeof(food)) ; } file.close() ; temp.close() ; } //********************************************************** // THIS FUNCTION GIVES THE CODE NO. TO DELETE RECORD FROM // THE FOOD FILE (FOOD.DAT) //********************************************************** void food :: delete_item(void) { clrscr() ; char t_code[5], ch ; int t, tcode ; gotoxy(3,25) ; cout <<"Press <ENTER> to see the list" ; gotoxy(5,3) ; cout <<"Enter Item Code of the item to be deleted : " ; gets(t_code) ; t = atoi(t_code) ; tcode = t ; if (t_code[0] == '0') return ; if (tcode == 0) { list_of_item() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"Press <ENTER> to Exit" ; gotoxy(5,24) ; cout <<"Enter Item Code of the item to be deleted : " ; gets(t_code) ; t = atoi(t_code) ; tcode = t ; if (tcode == 0) return ; }

clrscr() ; if (!item_found(tcode)) { gotoxy(5,5) ; cout <<"\7Record not found" ; getch() ; return ; } display_record(tcode) ; do { gotoxy(1,8) ; clreol() ; gotoxy(5,8) ; cout <<"Do you want to delete this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; delete_record(tcode) ; gotoxy(5,15) ; cout <<"\7Record Deleted" ; getch() ; } //********************************************************** // THIS FUNCTION MODIFY THE RECORD FOR THE GIVEN CODE FROM // THE FOOD FILE (FOOD.DAT) //********************************************************** void food :: modify_record(int tcode) { int recno ; recno = recordno(tcode) ; int valid, t_code ; char ch, t_itemcost[10], t_itemprice[10], t_itemcode[5] ; gotoxy(71,2) ; cout <<"<0>=Exit" ; gotoxy(5,12) ; cout <<"Item Code : " ; gotoxy(5,14) ; cout <<"Item Name : " ; gotoxy(5,16) ; cout <<"Item Cost : " ; gotoxy(5,18) ; cout <<"Item Price : " ; do { gotoxy(20,12) ; clreol() ;

cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,12) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER ITEM CODE TO ADD IN THE MENU" ; gotoxy(5,12) ; cout <<"Item Code : " ; gets(t_itemcode) ; t_code = atoi(t_itemcode) ; if (t_code == 0) return ; if (item_found(t_code) && t_code != tcode) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 CODE ALREADY GIVEN" ; getch() ; } } do { gotoxy(20,14) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,14) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER ITEM NAME TO ADD IN THE MENU" ; gotoxy(5,14) ; cout <<"Item Name : " ; gets(itemname) ;

strupr(itemname) ; if (itemname[0] == '0') return ; if ((strlen(itemname) < 1) || (strlen(itemname) > 20)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 1..20" ; getch() ; } } do { gotoxy(20,16) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,16) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER ITEM COST TO ADD IN THE MENU" ; gotoxy(5,16) ; cout <<"Item Cost : " ; gets(t_itemcost) ; itemcost = atof(t_itemcost) ; if (t_itemcost[0] == '0') return ; if (itemcost < 1 || itemcost > 800) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 1..800" ; getch() ; } } do { gotoxy(20,18) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0')

return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,18) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER ITEM PRICE TO ADD IN THE MENU" ; gotoxy(5,18) ; cout <<"Item Price : " ; gets(t_itemprice) ; itemprice = atof(t_itemprice) ; if (t_itemprice[0] == '0') return ; if (itemprice < itemcost || itemprice > 1000) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = " <<itemcost <<"..1000" ; getch() ; } } do { gotoxy(1,21) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,21) ; cout <<"Do you want to save this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; itemcode = t_code ; cout <<"\n" <<itemname ; cout <<itemcost ; cout <<itemprice ; getch() ; fstream file ; file.open("FOOD.DAT", ios::out | ios::ate) ; int location ; location = (recno-1) * sizeof(food) ; file.seekp(location) ; file.write((char *) this, sizeof(food)) ;

file.close() ; sort() ; clrscr() ; gotoxy(5,15) ; cout <<"\7Record Modified" ; getch() ; } //********************************************************** // THIS FUNCTION GIVES THE CODE NO. TO MODIFY RECORD FROM // THE FOOD FILE (FOOD.DAT) //********************************************************** void food :: modify_item(void) { clrscr() ; char t_code[5], ch ; int t, tcode ; gotoxy(3,25) ; cout <<"Press <ENTER> to see the list" ; gotoxy(5,3) ; cout <<"Enter Item Code of the item to be Modify : " ; gets(t_code) ; t = atoi(t_code) ; tcode = t ; if (t_code[0] == '0') return ; if (tcode == 0) { list_of_item() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"Press <ENTER> to Exit" ; gotoxy(5,24) ; cout <<"Enter Item Code of the item to be modify : " ; gets(t_code) ; t = atoi(t_code) ; tcode = t ; if (tcode == 0) return ; } clrscr() ; if (!item_found(tcode)) { gotoxy(5,5) ; cout <<"\7Record not found" ; getch() ; return ; }

display_record(tcode) ; do { gotoxy(5,8) ; cout <<"Do you want to Modify this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; modify_record(tcode) ; } //********************************************************** // THIS FUNCTION SORT THE RECORD IN THE FOOD FILE (FOOD.DAT) // ACCORDING TO THE CODE NOS. //********************************************************** void food :: sort(void) { int i=0,j ; food arr[100] ; food temp ; fstream file ; file.open("FOOD.DAT", ios::in) ; file.seekg(0,ios::beg) ; while (file.read((char *) &arr[i], sizeof(food))) i++ ; int size ; size = i ; file.close() ; for (i=1; i<size; i++) for (j=0; j<size-i; j++) { if (arr[j].itemcode > arr[j+1].itemcode) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } file.open("FOOD.DAT", ios::out) ; for (i=0; i<size; i++) file.write((char *) &arr[i], sizeof(food)) ; file.close() ; } //**********************************************************

// THIS FUNCTION PURCHASES THE FOOD ITEM IN THE MENU //********************************************************** void food :: purchase(void) { clrscr() ; account a ; int t_billno, purchased=0 ; t_billno = a.last_billno() ; t_billno++ ; char t_code[5], ch, t_quantity[5] ; int t, tcode, i=0, valid ; float qty ; int t_itemcode ; float t_qty, t_cost, t_price ; char t_itemname[30] ; struct date d; int d1, m1, y1 ; getdate(&d); d1 = d.da_day ; m1 = d.da_mon ; y1 = d.da_year ; do { clrscr() ; gotoxy(3,25) ; cout <<"Press <ENTER> to see the list" ; gotoxy(5,3) ; cout <<"Enter Item Code of the item to be Purchase : " ; gets(t_code) ; t = atoi(t_code) ; tcode = t ; if (t_code[0] == '0') { if (purchased) a.prepare_bill(t_billno) ; return ; } if (tcode == 0) { list_of_item() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"Press <ENTER> to Exit" ; gotoxy(5,24) ; cout <<"Enter Item Code of the item to be Purchase : " ; gets(t_code) ; t = atoi(t_code) ; tcode = t ; if (tcode == 0)

{ if (purchased) a.prepare_bill(t_billno) ; return ; } } clrscr() ; if (!item_found(tcode)) { gotoxy(5,5) ; cout <<"\7Item Code not found" ; getch() ; if (purchased) a.prepare_bill(t_billno) ; return ; } gotoxy(60,2) ; cout <<"Date:" <<d1 <<"/" <<m1 <<"/" <<y1 ; display_record(tcode) ; do { valid = 1 ; gotoxy(1,8) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER QUANTITY TO BE PURCHASE IN Kg." ; gotoxy(5,8) ; cout <<"Quantity : " ; gets(t_quantity) ; qty = atoi(t_quantity) ; if (t_quantity[0] == '0') { if (purchased) a.prepare_bill(t_billno) ; return ; } if (qty < 1 || qty > 800) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 1..800" ; getch() ; } } while (!valid) ; do { gotoxy(5,10) ; clreol() ; gotoxy(5,10) ; cout <<"Do you want to cancel this purchase (y/n) : " ;

ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') { purchased = 1 ; fstream file ; file.open("FOOD.DAT", ios::in) ; file.seekg(0,ios::beg) ; while (file.read((char *) this, sizeof(food))) { if (itemcode == tcode) { t_itemcode = itemcode ; strcpy(t_itemname,itemname) ; t_cost = itemcost ; t_price = itemprice ; t_qty = qty ; a.add_bill(t_billno,t_itemcode,t_itemname,t_qty,t_cost,t_price) ; i++ ; break ; } } file.close() ; } do { gotoxy(5,12) ; clreol() ; gotoxy(5,12) ; cout <<"Do you want to purchase more (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; } while (ch == 'Y') ; a.prepare_bill(t_billno) ; } //********************************************************** // THIS FUNCTION RETURNS THE BILL NO. OF THE LAST RECORD // IN THE BILL FILE (BILL.DAT) //********************************************************** int account :: last_billno(void) { fstream file ; file.open("BILL.DAT", ios::in) ; file.seekg(0,ios::beg) ; int t=0 ;

while (file.read((char *) this, sizeof(account))) t = billno ; file.close() ; return t ; } //********************************************************** // THIS FUNCTION ADDS THE RECORD IN THE BILL FILE (BILL.DAT) //********************************************************** void account :: add_bill(int t_billno, int t_itemcode, char t_itemname[30], float t_qty, float t_cost, float t_price) { struct date d; int d1, m1, y1 ; getdate(&d); d1 = d.da_day ; m1 = d.da_mon ; y1 = d.da_year ; dd = d1 ; mm = m1 ; yy = y1 ; code = t_itemcode ; strcpy(name,t_itemname) ; cost = t_cost ; price = t_price ; quantity = t_qty ; billno = t_billno ; fstream file ; file.open("BILL.DAT", ios::out | ios:: file.write((char *) this, sizeof(account)) ; file.close() ; } //********************************************************** // THIS FUNCTION PREPARES AND DISPLAYS THE BILL FOR THE // GIVEN BILL NO. ACCORDING TO PURCHASES MADE. //********************************************************** void account :: prepare_bill(int t_billno) { clrscr() ; struct date d; int d1, m1, y1 ; getdate(&d); d1 = d.da_day ; m1 = d.da_mon ;

app ) ;

y1 = d.da_year ; float total=0.0, total_bill=0.0 ; gotoxy(33,3) ; cout <<"CUSTOMER BILL" ; gotoxy(32,4) ; cout <<"~~~~~~~~~~~~~~~" ; gotoxy(55,5) ; cout <<"Date:" <<d1 <<"/" <<m1 <<"/" <<y1 ; gotoxy(8,7) ; cout <<"ITEMS PURCHASED" ; gotoxy(8,8) ; cout <<"~~~~~~~~~~~~~~~" ; gotoxy(8,9) ; cout <<"Item code Item name Cost Price Qty Total" ; gotoxy(8,10) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; int row=11 ; fstream file ; file.open("BILL.DAT", ios::in) ; file.seekg(0) ; while (file.read((char *) this, sizeof(account))) { if (billno == t_billno) { gotoxy(8,5) ; cout <<"BILL NO. # " <<billno ; gotoxy(8,6) ; cout <<"~~~~~~~~~~~~~~~" ; gotoxy(10,row) ; cout <<code ; gotoxy(18,row) ; cout <<name ; gotoxy(39,row) ; cout <<cost ; gotoxy(47,row) ; cout <<price ; gotoxy(56,row) ; cout <<quantity ; total = quantity * price ; gotoxy(63,row) ; cout <<total ; total_bill = total_bill + total ; row++ ; } } file.close() ; gotoxy(39,row+1) ; cout <<"TOTAL BILL: Rs." <<total_bill <<" /=" ; getch() ;

} //********************************************************** // THIS FUNCTION DISPLAYS THE LIST OF THE BILLS //********************************************************** void account :: bill_list(void) { clrscr() ; fstream file ; file.open("BILL.DAT", ios::in) ; file.seekg(0) ; int row=5, found=0, pageno=1, prev_billno=0, flag=0 ; float total=0.0, total_bill=0.0 ; gotoxy(30,2) ; cout <<"LIST OF BILLS" ; gotoxy(29,3) ; cout <<"~~~~~~~~~~~~~~~" ; gotoxy(3,4) ; cout <<"Billno. Date Item Code Item name Cost Price Qty Total" ; gotoxy(3,5) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~" ; while (file.read((char *) this, sizeof(account))) { row++ ; delay(20) ; found = 1 ; if (prev_billno != billno) { if (flag) { gotoxy(52,row) ; cout <<"TOTAL BILL: Rs." <<total_bill <<"/=" ; total_bill = 0.0 ; row++ ; } gotoxy(4,row) ; cout <<billno ; } flag = 1 ; gotoxy(11,row) ; cout <<dd <<"/" <<mm <<"/" <<yy ; gotoxy(24,row) ; cout <<code ; gotoxy(32,row) ; cout <<name ; gotoxy(52,row) ;

cout <<cost ; gotoxy(59,row) ; cout <<price ; gotoxy(67,row) ; cout <<quantity ; total = quantity * price ; gotoxy(73,row) ; cout <<total ; total_bill = total_bill + total ; if ( row >= 23 ) { row = 5 ; gotoxy(66,1) ; cout <<"Page no. : " <<pageno ; pageno++ ; gotoxy(1,25) ; cout <<"Press any key to continue..." ; getche() ; clrscr() ; gotoxy(30,2) ; cout <<"LIST OF BILLS" ; gotoxy(3,4) ; cout <<"Billno. Date Item Code Item name Total" ;

Cost Price Qty

gotoxy(3,5) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~" ; } prev_billno = billno ; } row++ ; gotoxy(52,row) ; cout <<"TOTAL BILL: Rs." <<total_bill <<"/=" ; if ( !found ) { gotoxy(5,10) ; cout <<"\7Records not found" ; } gotoxy(66,1) ; cout <<"Page no. : " <<pageno ; gotoxy(1,25) ; cout <<"Press any key to continue..." ; getche() ; file.close () ; } //********************************************************** // THIS FUNCTION IS THE MAIN FUNCTION CALLING THE MAIN MENU

//********************************************************** void main(void) { clrscr() ; menu m ; m.main_menu() ; }

OUTPUT

Enter Choice : 0: QUIT 4: TOTAL BILL 3: EDIT 2: SEE MENU 1: PURCHASE FAST FOOD ~~~~~~~~~~~~~

Page no. : 1 LIST OF ITEMS ~~~~~~~~~~~~~~~ ITEM CODE ITEM NAME ITEM COST ITEM PRICE ===============

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 2 3 4 5 BURGER CHIPS MINERAL WATER COLD DRINK COLD DRINK(500ML) 10 20 10 10 20 12 25 12 12 25

Press any key to continue...

Page no. : 1 LIST OF BILLS ~~~~~~~~~~~~~~~ Billno. Date Item Code Item name Cost Price Qty Total

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 21/10/2009 1 BURGER TOTAL BILL: Rs.12/= 2 21/10/2009 1 BURGER 10 12 10 120 10 12 1 12

TOTAL BILL: Rs.120/= 3 21/10/2009 1 BURGER 10 12 10 120

TOTAL BILL: Rs.120/=

Press any key to continue...

<0>=Exit ADD FOOD ITEM TO THE MENU ~~~~~~~~~~~~~~~~~~~~~~~~~~~

Item Code : 6

Item Name :

Item Cost :

Item Price :

ENTER ITEM NAME TO ADD IN THE MENU

<0>=Exit Item Code : Item Name : Item Cost : Item Price : 1 BURGER 10 12

Do you want to Modify this record (y/n) : Y

Item Code : Change (y/n) : N

Item Name : Change (y/n) : N

Item Cost : Change (y/n) : N

Item Price :

ENTER ITEM PRICE TO ADD IN THE MENU

Item Code : 1 Item Name : BURGER Item Cost : 10 Item Price : 12

Do you want to delete this record (y/n) : N

Enter Choice : 0: EXIT 3: DELETE ITEM 2: MODIFY ITEM 1: ADD ITEM EDIT MENU ~~~~~~~~~~~~~

Introduction to C + +

C++ is an extension of C language which is widely used all over . It is a powerful modern language that combines the power , elegance and flexibility of C and the features of Object Oriented Programming (OOP) . It is faster and more powerful than Java , another popular object oriented language , which lacks certain features like pointers and multiple inheritance . With its object oriented capabilities , such as , data abstraction Inheritance and polymorphism , C++ offers significant software engineering benefits over any other programming language . Programming Pundits expect that C++ will replace C as a general purpose programming language in the near future . C++ is the language of the future .

History of C++ C++ is an object oriented language . It was developed Bjarne Stroustrup at AT&T Bell Laboratories in Murray Hill , New Jersey , USA , in the early 1980s . Stroustrup , an admirer of Simula 67 and a strong supporter of C , wanted to combine the best of both the languages and create a more powerful language that could support OOP features and still retain the power and elegance of C . The result was C++ . Therefore , C++ is an extension of C with major addition of the class construct feature of Simula 67 . Since the class was a major addition to the original C language , Stroustrup initially called the new language C With Classes . However , later in 1983 , the name was changed to C++ . The idea of C++ comes from the increment operator ++ , thereby , suggesting that C++ is an augmented (incremented) version of C .

During the early 1990s , the language underwent a no. of improvements and changes . In November 1997 , the ANSI / ISO standards committee standardized these changes and added several new features to the language specifications .

WHAT IS OOP ? The major motivating factor in the invention of object oriented approach is to remove some of the flaws encountered in the procedural approach . OOP treats data as a critical element in the program development and does not allow it to flow freely around the system . It ties data more closely to the functions that operate on it , and protects it from accidental modifications from outside functions . It allows decomposition of problems into a number of entities called Objects and then builds data and functions around these objects . The organization of data and functions in OOP is shown below :

Striking features of OOP Emphasis on data rather than procedure . Programs are divided into objects . Data structures are designed such as they characterize the objects . Functions that operate on the data of an object are tied together in the data structure . Data is hidden and can not be accessed by external functions . Objects may communicate with each other through functions . New data and functions can be easily added wherever necessary . Follows bottom - up approach in program design .

Basic concepts in OOP

1. Objects - are the basic run time entities in object oriented system . They may represent a person , a place , a bank account , a table of data or any item that the program has to handle . They may represent user-defined data such as vectors , time and list . When a program is executed , the objects interact by communicating with each other . Each object contains data and code for manipulation

2 . Classes - The entire set of data and code of an object can be made user defined type with the help of a class . Once a class have been defined , we can create any no. of objects belonging to that class . Each object is associated with the data of type class with which they are created . A class is thus a collection of objects of similar type . For e.g. , mango , apple , banana etc . all are the members of class fruit . Classes are built - in data types and behaves like built in types of a programming language .

3 . Data Abstraction & Encapsulation - The wrapping up of data & functions into a single unit (called class) is known as Encapsulation . It ia the most striking feature of a class . The data is not accessible to the outside world , and only those functions which are wrapped in the class can access it. These

functions provide the interface between the objects data and the program . This insulation of data of data from direct access by the program is called Data Hiding or Information - hiding . Abstraction refers to the act of representing essential features without including the background details . Classes use the concept of abstraction and are defined as list of abstract attributes , such as , size , weight , cost and functions . Functions that operate on these data are called methods or member functions .

4 . Inheritance - It is the process by which objects of one class can acquire the properties of another class . It supports the concept of hierarchical classification . For e.g., scooter is a part of 2- wheelers which is again a part of class vehicles . The principle behind this sort of division is that each derived class shares common characteristics with the class from which it is derived . 5 . Polymorphism -It means the ability to take more than one forms .An operation may exhibit different behaviors in different instances that which depends upon the type of data used in the operation . For e.g., Consider + operator . For two nos. it will generate the sum , but for two strings , it will concatenate them . When a single function name is used to handle different no. and different type of arguments , it is called Function Overloading .

6 . Dynamic Binding - It refers to the linking of the procedure call to the code to be executed in response to the call . It means that the code associated with a given procedure call is known until the time of the call at the run - time . It is associated with polymorphism and inheritance .

7 . Message Passing - An OO program consists of a set of objects that communicate with each other . The process of programming in an OO language , therefore , involves :

a) creating classes that define objects and their behavior . b) creating objects from class definitions . c) establishing communication among objects . The concept of message passing makes it easier to talk about building systems that directly model or simulate their real - world counterparts .

APPLICATIONS OF C++
C++ is a versatile language for handling very large programs . It is suitable for virtually any programming task including editors , compilers , data base systems , communication systems and any complex real life application systems .

C++ allows us to create hierarchy related objects . So , we can build special object oriented libraries which can be used later by many programmers . While C++ is able to map the real world problems the C part of C++ gives the language the ability to get close to the machine language details C++ programs are easily maintainable and expandable . It is expected that C++ will replace C as a general purpose language in the near future .

You might also like