Sie sind auf Seite 1von 21

STANDARD XII

COMPUTER SCIENCE
Name of the student :……………………………………………………

Class :…………………………………………………….

Division :…………………………………………………….

Register No. :……………………………Year:..................


Certified that this is a bonafide record of project work of
………………………………………………………………………………………with
Register Number…………………………………………in year…………………

Date :…………….. Teacher in-charge Principal


_______________________________________________________________

Submitted for the practical exam. held on ………………………


Office Seal 1.Examiner
Date :……………….
Place :………………. 2.Examiner

1
CONTENTS
SNO. TOPIC PAGE NO.
1. Certificate 2
2. Acknowledgement 4
3. Aim and Objective 5
4. Introduction to C++ 6
5. Requirement 8
6. Introduction to program 9
7. Header files used and 10
their purpose
8. Program coding 11
9. Output 17
10. Conclusion 21
11. Bibliography 22

2
ACKNOWLEDGEMENT
I'd like to express my greatest gratitude to the people who have
helped and supported me throughout my project.
I'm grateful to Mrs. Deepa Madhavan for her continuous support
for the project ,from initial advice and encouragement to this day.

Special thanks of mine goes to my colleague who helped me in


completing the project by giving interesting ideas , and thoughts
and made this project easy and accurate.

I wish to thank my parents for their undivided support and interest


who inspired me and encouraged me to go my own way,without
which I would be unable to complete my project. At last but not
the least I want to thank my friends who appreciated me for my
work and motivated me and finally to God who made all the
things possible.

3
AIM AND OBJECTIVE
This project uses the concept of data file handling ,object oriented
programming and other techniques. This project aims to enable
users keep a secure record of the details of Food.

Here you can keep record of details of Food. This project helps to
store data in a very easily accessible way instead of storing data
in huge bulks of files.

4
INTRODUCTION TO C+
+
C++ was developed by Bjarne Stroustrup of AT and T Bell
laboratories in the early 1980's , and is a pun-"++" is a syntactic
construct used in C(to increment a variable), and C++ is intended
as an increment improvement of C.Most of C is a subset of C++ ,
so that most C programs can be compiled(i.e. converted into a
series of low level instructions that the computer can execute
directly) using a C++ compiler.

C is in many ways hard to categorize .Compared to assembly


language it is high-level ,but it nevertheless includes many low-
level facilities to directly manipulate the computer's memory. It is
therefore an excellent language for writting efficent "systems"
programs.But for other typpes of programs,C code can be
particularly prone to certain types of errors.The extra object
oriented facilities in C++ are partly included to overcome these
shortcomings.

The American National standards Institutions (ANSI) provides


"official" and generally accepted standard definition of many
programming languages , including C and C++ .Such standards
are important .A program wriiten only in ANSI C++ is guranteed to
run on any computer whose supporting software confirms to the
ANSI standard .In other words,the standard gurantees that ANSI
5
C++ programs are portable .In practice most versions of C++
include ANSI C++ as a core language ,but also include extra
machine-dependent features to allow smooth interaction with
different computers' operating systems.these machine dependent
features should be used sparingly .Moreover, when parts of a C++
program use non-ANSI components of the language,these should
be clearly marked, and as far as possible separated from the rest
of the program,so as to make modification of the program for
different machines and operating system as easy as possible.
These are several editors available for UNIX-based systems.Two
of the most popular editors are emacs and vi. For the compiler
and linker ,we will be using the GNU C++ compiler/linker,and for
the debugger we will be using the GNU debugger gdb.

For those that defer and intergrated development environment


(IDE) that combines an editor ,a linking program and a debugger
in single programming environment (in similar way to Microsoft
developer studio window NT ), there are also IDEs available for
UNIX (e.g. Eclipse ,Xcode.kdevelop etc.)

6
REQUIREMENT
Hardware Required:
Printer ,to print the required documents of the project
Compact Drive
Processor :Pentium 111
Ram :64 MB
Harddisk :20 Gb.

Software Required:
Operating system :Windows XP
Turbo C++ ,for execution of program and
MS word , for presentation of output.

7
INTRODUCTION TO PROGRAM

The project ,named "FOOD DATABASE” enables the user to keep


a constantly updated record of Food and their details. Which can
easily be accessed.
The user is provided with 5 options :
1) Add : This function enables the user to add more details to the
existing file.
2) Insert : This function helps the user to insert into an existing
file.
3) Search : This function helps the user to search details of Food.
4) Display : This function helps user to view details of Food.
5) Update : This function helps user to modify details and change
the info of different records of Food.

8
HEADER FILES AND THEIR
PURPOSE

1.FSTREAM.H For file handling ,cin and cout


2.CONIO.H For clrscr() and getch ()
functions
3.STDIO.H For standard I/O operations
4.STRING.H For string handling

9
PROGRAM CODING
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class fmenu
{int fid;
char name[20] ;
float price;
char cuisine[20];
public:
void read();
void display();
void modify();
int getfid()
{return fid;
}
};
void fmenu::read()
{cout<<"Enter Food ID No.\n";
cin>>fid;
cout<<"Enter Food Name\n";
gets(name);
cout<<"Enter Price\n";
cin>>price;
cout<<"Enter Cuisine\n";
gets(cuisine);

10
}
void fmenu::display()
{cout<<"\nFood ID No.- "<<fid;
cout<<"\nFood Name-";puts(name);
cout<<"Price:-"<<price;
cout<<"\nCuisine:- "<<cuisine<<'\n';
}
void fmenu::modify()
{char name1[20], cuisine1[20];int fid1;float
price1;
cout<<"Enter New Food ID No.\n";
cin>>fid1;
cout<<"Enter New name\n";
gets(name1);
cout<<"Enter New Price\n";
cin>>price1;
cout<<"Enter New Cuisine\n";
cin>>cuisine1;
strcpy(name,name1);
fid=fid1;
strcpy(cuisine,cuisine1);
price=price1;
}
fmenu s,s1;
void add()
{char ch;
ofstream fout("fmnu",ios::binary);
do{s.read();
fout.write((char*)&s,sizeof(s));
cout<<"Do you want to continue?\n";

11
cin>>ch;
}
while(ch=='y'||ch=='Y');
}
void show()
{ifstream fin("fmnu",ios::binary);
while(fin.read((char*)&s,sizeof(s)))
{
s.display();
}
}
void insert()
{int flag=0;
ifstream fin("fmnu",ios::binary);
ofstream fout("ftemp",ios::binary);
cout<<"Enter the details to be inserted\n";
s1.read();
while(fin.read((char*)&s,sizeof(s)))
{if(s.getfid()>=s1.getfid())
{fout.write((char*)&s1,sizeof(s1));
fout.write((char*)&s,sizeof(s));
flag=1;
break;
}
else
fout.write((char*)&s,sizeof(s));
}
if( flag==0)
fout.write((char*)&s,sizeof(s));
while(fin.read((char*)&s,sizeof(s)))

12
{fout.write((char*)&s,sizeof(s));
}
remove("fmnu");
rename("ftemp","fmnu");
}
void delet()
{int flag=0,r;
ifstream fin("fmnu",ios::binary);
ofstream fout("ftemp",ios::binary);
cout<<"Enter the Food ID no to be deleted\n";
cin>>r;
while(fin.read((char*)&s,sizeof(s)))
{if(s.getfid()==r)
{flag=1;
cout<<"\nRecord deleted successfully\n";
}
else
fout.write((char*)&s,sizeof(s));
}
if(flag==0)
cout<<"Record not found";
remove("fmnu");
rename("ftemp","fmnu");
}
void modify()
{int r;
fstream fin("fmnu",ios::in|ios::out|
ios::binary);
cout<<"Enter the Food ID No to be modified";
cin>>r;

13
while(fin.read((char*)&s,sizeof(s)))
{if(s.getfid()==r)
{s1.modify();
int pos=fin.tellg()-sizeof(s);
fin.seekp(pos);
fin.write((char*)&s1,sizeof(s));
}
}
}
void search()
{int r,flag=0;
fstream fin("fmnu",ios::in|
ios::out,ios::binary);
cout<<"Enter the Food ID no to be searched";
cin>>r;
while(fin.read((char*)&s,sizeof(s)))
{if(s.getfid()==r)
{s.display();
flag=1;
break;
}}
if(flag==0)
cout<<"Record not found";
}
void main()
{clrscr();
cout<<"\t\t\tFOOD DATABASE \n";
int ch;char ch1;
do
{cout<<"\n1.Add details";

14
cout<<"\n2.Display all details";
cout<<"\n3.Insert any new details";
cout<<"\n4.Delete any detail";
cout<<"\n5.Modify any detail";
cout<<"\n6.Search for a record";
cout<<"\nEnter your choice\n";
cin>>ch;
switch(ch)
{case 1:add();
break;
case 2: show();
break;
case 3:insert();
break;
case 4:delet();
break;
case 5: modify();
break;
case 6:search();
break;
default:cout<<"Invalid choice";
}cout<<"\nDo you want to continue to add or
show?\n";
cin>>ch1;
}
while(ch1=='y'||ch1=='Y');
getch();
}

15
16
17
18
19
CONCLUSION
This program helps you to record the details of each Food
separately.

It also helps to update various records.

C++ makes our work easier so that we can make utilize of the
record of Food whenever required.

20
BIBLIOGRAPHY
 www.google.com

 www.cbse.nic.in

 Introduction to C++ by Sumita Arora

21

Das könnte Ihnen auch gefallen