0% found this document useful (0 votes)
73 views

Industrial Training Report: June - July 1997

This industrial training report summarizes George Joseph's 6-week internship developing a university student database using object-oriented programming. The report includes an introduction to databases and object-oriented programming, a discussion of key object-oriented programming concepts like classes and objects, and an overview of the software design for the university student database project.

Uploaded by

Aditi Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Industrial Training Report: June - July 1997

This industrial training report summarizes George Joseph's 6-week internship developing a university student database using object-oriented programming. The report includes an introduction to databases and object-oriented programming, a discussion of key object-oriented programming concepts like classes and objects, and an overview of the software design for the university student database project.

Uploaded by

Aditi Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

INDUSTRIAL TRAINING REPORT

JUNE – JULY

1997

TOPIC :

UNIVERSITY STUDENT

DATABASE :

AN OBJECT - ORIENTED APPROACH

BY:

GEORGE JOSEPH
B.E. (E & C) IV YEAR

DEPARTMENT OF
ELECTRONICS AND COMPUTER ENGINEERING
UNIVERSITY OF ROORKEE
ROORKEE – 247 667 U.P. (INDIA)
CANDIDATE DECLARATION

I hereby certify that the work which is presented in the industrial Training Report entitled
“UNIVERSITY STUDENT DATABASE: AN OBJECT-ORIENTED APPROARCH” in
fulfillment of the requirement for the industrial Training is an authentic record of my
work carried out for a period of Six weeks, from 1/June/97 to 20/July/97, under the
supervision and guidance of Dr. R.C. Joshi, Professor, Head of Department, Electronics
and Computer Engineering and Coordinator of New Computational Facilities (NCF)

Date : …………………………………… ……………………..

George Joseph

CERTIFICATE

This is to certify that the above statement made by the candidate is correct to the
best of my knowledge.

………………………
Dr. R.C. Joshi
Coordinator NCF
Professor and Head
Department of Electronics &
Computer Engineering
University of Roorkee
Roorkee- 247 667 U.P (INDIA)
ACKNOWLEDGMENT

We are grateful to the Department of Electronics and Computer Engineering, for


providing facilities and a environment conducive to doing our Industrial Training.

We thank the staff of University of Roorkee Computer Center for their excellent
professional work.

We would like to express our deep gratitude to Dr. R.C. Joshi, Professor, Head of
Department Electronics and Computer Engineering and Coordinator of New
Computational Facilities (NCF) whose guidance and support was of Great value in our
professional development.

………………………

George Joseph
CONTENTS

S. No. Chapter Page No.

1. Introduction 1
2. Object – Oriented Programming 2
3. Data Management 10
4. Software Design 12
5. Conclusion 18
6. References 19
7. Program Listing 21
1: AN INTRODUCTION

Database

An up datable storage of information of an application’s world and managing soft ware,


that conceals from the user the physical aspects of information storage and information
representation. The information stored in a database is accessible at a logical level
without involving the physical concepts of implementation.

Object oriented programming

Although the principles of structured programming improved the clarity, reliability, and
ease of maintenance of programs, large scale programming still remains a challenge.
Object-oriented programming (OOP) brings a new approach to that challenge. Unlike
procedural programming, which emphasizes algorithms, OOP emphasizes the data.
Rather that trying to fit a problem to the procedural approach of a language, OOP
attempts to fit a problem. The idea is to design a data from that corresponds to the
essential features of a problem. In C++, class is a specification describing such a new
data form, and an object is a particular data structure constructed according to that plan.
For instance a class could describe the general properties of a corporation executive
(name, tile, salary, unusual abilities, etc.), while an object would represent a specific
executive. In general, a class defines what data is used to represent an object and the
operations that can be performed upon that data.

The OOP approach to program design is to firs design classes that accurately represent
those this with which the program deals. The class definitions, recall, include a
description of permissible operations for each class, such as moving a circle or rotating a
line. Then you proceed to design a program using objects of those classes. The process
of going from a lower level of organization, such as classes, to a higher level such as
program design, is called bottom-up programming.

There is more to OOP programming than the binding of data and methods into a class
definition. OOP, for example, facilitates creating reusable code, and that eventually can
saver a lot of work. Information hiding safeguards data from improper access.
Polymorphism lets you create multiple definitions for operators and functions; with the
programming context determining which definition is used. Inheritance lets you derive
new, classes from old ones. As you can see, OOP introduces man new ideas and involves
a different approach to programming than does procedural programming. Instead of
concentrating on task, you concentrate on representing concepts. Instead of taking a top-
down programming approach, you sometimes take a bottoms-up approach.
2: OBJECT ORIENTED PROGRAMMING

WHAT IS OOP?

OOP (Object Oriented Programming is a new way of organizing programs. It has


nothing to do with any programming language, although a programming language that
supports OOP makes it easier to implement the OOP techniques. Simply stated, OOP is
an approach to software design in which the decomposition of a system is based upon the
concept of an object. An object is an entity whose behavior s characterized by the actions
that it suffers and that it requires of other objects. Object-Oriented Development is
fundamentally different from traditional Functional (Structured) methods for which the
primary criteria for decomposition is that each module in the system represents a major
step in the overall process.

OOP is a method of designing and implement software. The use of OOP in itself does
not impart anything to a finished software product that the user can see. However, the
software developer may gain some advantages by using OOP methods, especially in large
Software projects. Because OOP allows one to remain close to the conceptual, higher
level model of the real-world problems one is trying to solve, one can manage the
complexity better with it, than with approaches that force one to map the problem to fit
the features of the language. On can take advantage of modularity of objects and
implement the program in relatively independent units that are separately maintainable.
On can also share code and data among objects through inheritance.

FEATURES OF OBJECT – ORIENTED LANGUAGE.

A few if the major elements of object-oriented languages in general and C++ in particular
are examined below:

Objects

 When one approaches a programming problem in an object-oriented language,


one no longer asks how the problem will be divided into functions, but how will
be divided into object. Thinking in terms of objects, rather than functions, has a
surprisingly helpful effect on how easily programs can be designed. This results
from the close match between objects in the programming sense and objects in the
real world.

“What kind of things become objects in object-oriented programs?” The answer


to this is limited only by ones imagination, but some typical categories are given
below to start one thing king:

* Physical Objects
Automobiles in a traffic-flow simulation
Electrical components in a circuit-design program
Countries in an air-traffic control system
 Elements of the computer-user environment

Windows
Menus
Graphics objects (lines, rectangles, circles)
The mouse and the keyboard

 Programming Constructs

Customized arrays
Stacks
Linked Lists
Binary Trees

 Collection of Data

An inventory
A personal file
A table of the latitudes and longitudes of would cities

 User – defined data types

Time
Angles
Complex numbers
Point on the plane

 Components in computer games

Ghosts in a maze game


Positions in a board game (chess, checkers)
Animals in an ecological simulation
Opponents and friends in adventure games (Prince)

The match between programming objects and real-world objects is the happy result of
combining data and functions: The resulting objects offer a revolution in program
designs. No such close match between programming constructs and the items being
modeled exists in a procedural language.

Class

A class is specified as a means of grouping all the object which share the same of
attributes (data member functions (Methods). An object must belong to only one class as
an instance of that class. The relationship between an object and its class is the familiar
instance-of relationship. A class is similar to an abstract data type. A class may also be
primitive class is one which has associated instances, but which has no attributes, such as
integer, string, and Boolean.

The value of an attribute of an object, since it is necessarily an object, also belongs to


some class. This is called the domain of the attribute of the object.

Class Hierarchy and Inheritance

Object-oriented systems allow the users to derive a new class from an existing class,
called a subclass of the existing class inherits all the attributes and methods of the
existing class, called the super class of the class. The user may also specify additional
attributes and methods for the subclass. A class may have any number of subclasses.
Some systems allow a class to have only one super class, while other allow a class to
have any number of super classes. In the former, a class inherits attributes and methods
from only one class; this is called single inheritance. In the latter, a class inherits
attributes and methods from more than one super class; this is called multiple inheritance.
In a system which supports single inheritance, the classes form a hierarchy, called a class
hierarchy. If the system supports multiple inheritance, the classes form a rooted directed
graph sometimes called a class lattice. C++ supports both single and multiple inheritance.

Polymorphism

Polymorphism is the property that allows an operation to have different behavior on


different object. In other words, different objects react differently to the same message
(member function call).

Polymorphism in C++ is accomplished with virtual functions. Virtual functions let one
use many versions of some function throughout a class hierarchy, with the particular
version to be executed, being determined at run time (this is called late binding).

The other form of polymorphism is function overloading or functional polymorphism,


which enable on define several function having the same name as long as they have
different signatures (argument list). Its purpose is to let one use the same function name
for the same basic operation even though one is applying the operation to different data
types. As an example. Suppose a number of geometrical shapes understand the message
draw. Each object reacts to this message by displaying itself on a video display.
Obviously, a rectangle object will draw itself differently from a circle object.

Another form of polymorphism is Operation overloading which extends the overloading


concept to operators, letting one assign multiple meaning’s to the operators. Actually,
many C++ (and C) operators are already overloaded. For instance, the * operator, when
applied to an address, yields the stored at that address. But applying.* to two numbers
yields the product of the values. C++ uses the number and type of operands to decide
which action to take.
C++ lets one extend operator overloading to user-defined types, permitting one to use the
+ symbol to add two objects. Again, the compiler will use the number and type of
operands to determine which definition of addition to use. For example if the two objects
being added are character strings, the addition will result in a concatenation of one string
to the other. Polymorphism plays an important part in helping one to simplify the syntax
of performing the same operation on a collection of objects.

Constructor and Destructor

A constructor is a special function that is a class member bearing the same name as the
class. Its purpose is to build and initialize objects. A constructor is called within the
program to allocate space for an object and assign value to the object’s data members.
There may by any number of constructors in a given class, but with different parameters
or arguments. Constructors are just like other functions, in almost every way. They may
have parameters like other functions, but they cannot return any value. This restriction is
imposed because constructors are usually called when defining a new object, when is no
way to retrieve or examine any return value from a constructor.

A destructor is the reverse if a constructor, in that it frees up space used to store objects.
A destructor is a member function of a class and bears the same as the class, except
implicitly when a variable goes outside of its declared scop. Destructors for local
variables are called when the block in which they are declared becomes inactive.

Reusability

Once al class has been written, created, and debugged, it can be distributed to other
programmers for use in their own programs. This is called reusability. It is similar to the
way a library of functions in a procedural language can be incorporated into different
programs. However, in OOP, the concept of inheritance provides an important extension
to the ideas of reusability.

Object-Oriented Development

The object-oriented development consist of two phases, i.e., Analysis and Design.
Analysis is usually defined as a process of extracting user requirement and establishing
an accurate model of the problem domain. Design by contrast, is the process of mapping
requirements to a system implementers. While these tow activities are conceptually
distinct, in the line between analysis and design is frequently blured. Many of the
components of an analysis model have direct counterparts in a design model. In addition,
the process of design usually leads to a better understanding of requirements, and can
uncover areas where a change in requirements must be negotiated to support desired
performance and cost constraints. In recognition of these realities, analysis and design
must be performed iteratively, if not concurrently. One of the frequent advantages of
object orientation is that it provides a smoother translation between analysis and design
models than do structured methodogies.
Object-Oriented Analysis (OOA)

The primary goal of object-oriented analysis is the development of an accurate and


compete representation of the problem domain. The Coad and Yourdon object-oriented
analysis method is discussed in the following section.

Coad and Yourdon Object-oriented analysis

Coad and Yourdon view their OOA methodology as building “upon the best concepts
from information modeling, object-oriented programming languages and knowledge-
based system”. OOA results in a five-layer model of the problem domain, where each
layer builds on the previous layers. The layered model is constructed using a five-step
procedure:

1. Define object and class

Look for structures, other systems, devices, events, roles operational procedures
sits, and organizational units.

2. Define Structures

Look for relationship between classes and represent them as either general-to-
specific structures or whole-to-part structures.

3. Define subject areas

Examine top-level objects within whole-to-part hierarchies and mark these as


candidate subject areas. Refine subject areas to minimize interdependencies
between subject.

4. Define attributes

Identify the atomic characteristics of objects as attributes of the object. Also look
for associative relationship between objects and determine the cardinality of those
relationships.

5. Define services

For each class and object, identify all the services it performs, either on its own
behalf or for the benefit or other classes and objects.
Class and Object Diagram:

A complex diagram consisting of five layers, each adding a level of detail. The layers are

(1) Class and object layer, which connects and objects enclosed within boxes with
rounded corners.

(2) Structures layer, which connects classes and objects with arcs to show
generalization-specification and whole-part inheritance relationships.

(3) Subjects layer, which adds border around closely related classes.

(4) Attributes layer, which adds a list of attributes inside the class and object
boxes and identifies associative relationships between objects.

(5) Service layer, which adds a list of services inside the calls and object boxes
and provides arcs showing message connections between boxes.

Object-state diagram:

A simple diagram that shows all the possible states of an object and the allowed
transitions between states. States are enclosed within boxes and transitions are
represented as directed, unlabeled arcs between states.

Service chart

A flowchart-like diagram that depicts the detailed logic within a individual service,
including object-state changes that trigger or result from the service.

Coad and Yourdon explicitly support each of the essential principles of object
orientation. The class and objects diagram (levels 1,2 and 4) provides and object
classification and identifies potential inheritance relationships. In addition, encapsulation
of object is modeled trough the concept of exclusive services.

OBJECT-ORIENTED DESIGN (OOD)

Design is a process of mapping system requirements defined during analysis to an


abstract representation of a specific system-based implementation, meeting cost and
performance constraints. Now the Booch object object-oriented design method is
discussed.

Booch object-oriented design

Booch views his methodology as an alternative to, rather that an extension of, structured
design. Booch describes a host of techniques and tools to assist design, raning from
informal lists to formal diagrams and templates. There are four major steps that must be
followed during the course OOD:

1. Identify classes and object

Identify key abstractions in the problem space and label them as candidate classes
and objects.

2. Identify the semantics of classes and objects

Establish the meaning of the classes and objects identified in the previous step
using a variety of techniques, including creating “scripts” that define the life
cycles of each objects from creation to destruction.

3. Identify relationships between classes and objects

Establish class and object interactions, such as patterns of inheritance among


classes and patterns of cooperation among objects. This step also captures
visibility decisions among classes and objects.

4. Implement classes and objects

Construct detailed internal views of classes and object, including definitions of


their carious behaviours (services). Also, allocate objects and classes to modules
(as defined in the target language environment) and allocate programs to
processors (where the target environment supports multiple processors).

The primary tools used during OOD are

 Class diagrams and class templates, which emphasize class definitions and
inheritance relationships.

 Object diagrams and liming, which stress message definitions, visibility and
threads of control.

 State-transition diagrams to model objects and transitions.

 Operation templates to capture definitions of services

 Process diagrams and templates to assign modules to processors n situations


where a multiprocessor configuration will be used.
Class diagram/template

It shows the existence of classes (enclosed in dotted-line “clouds”) and their relationships
(depicted by various kinds of directed and undirected) in the logical design of a system.
Relationships supported included uses, instances, inherits, metaclass and undefined.

Object diagram/template

It is used to model some of dynamics of objects. Each object (enclosed in solid line
“clouds”) represents an arbitrary instance of a class. Objects are connected by directed
arcs that define object visibility and message connections. It does not show flow of
control or ordering of events.

Operation template

It is structured text that provides detailed design documentation for operations.

Process diagram/template

It is used to show the allocation of processes to processors in the physical design of a


system. It is required only for implementations in multiprocessor environments.

State transition diagram

It shows the states (depicted by circles) of a class, the events (directed arcs) that cause
transitions from one state to another, and the actions that result from a state change.

Timing diagram

It is a companion diagram to the object diagram, showing the flow of control and
ordering of events among a group of collaborating objects.

Booch OOD provides the widest variety of modeling tools of the OOD methodologies. It
provides a wealth of guidance on the design process by describing in detail the types of
activities that must be performed.

3: DATA MANAGEMENT

A data base is, fundamentally, body of information contained in a mechanism that


facilities the use of the information. A data base must be distinguished from the many
mechanisms available for managing records the envelopes in which information is
carried.

Why should we choose to store our operational data in an integrated database?


Lets us consider some of the advantages that accrue from having centralized control of
the data, as discussed above:

Redundancy can be reduced

In no database systems each application has its own private files. This can often lead to
considerable redundancy in stored data, with resultant waste in storage space.

Inconsistency can be avoided (to some extent)

This is really a corollary of the previous point.

The data can be shared

It means that, not only that existing applications can share the data in the database, but
also that new applications can be developed to operate against that same stored data. In
other words, the data requirements of new applications may be satisfied without having to
create any new stored files.

Standards can be enforced

With central control of the database, the DBA (Database admistrator) can ensure that all
allocable standards are followed in the representation of the data.

Security restrictions can be applied

Having complete jurisdiction over the operational data, the DBA

(a) Can ensure that the only means of access to the database is through the proper
channels

(b) Can define authorization checks to be carried out whenever access to sensitive
data is attempted.

Integrity can be maintained

The problem of integrity is the problem of ensuring that the data in the database is
accurate.

Generally the DBMSs have a three level architecture which is in agreement with the
proposals made by the ANSI/SPARC Shidy Group on DBMSs(2). The advantage of the
three level architecture is that it simplifies the design and management of the r database
system by providing a higher level of program/data independence.
 Conceptual level
 External level
 Internal level

A Data Manipulation Language (DML) is an essential tool provided by any DBMS to


access the database. It comprises two components.

 Query language
 Non – query language

Various languages have been developed for querying a relational database. These many
be categorized into:

 Languages based on Relational Algebra.


 Languages based on Relational Calculus.
SOFTWARE DESIGN

FILE ORGANIZATION AND ACCESS MODE

The technique used to represent and to store records on a file is referred to as file
organization. The three fundamental organization techniques that we will discuss in the
coming chapters are:

1. Sequential
2. Index sequential
3. Direct access (Relative)

It is the file organization that determiners files record ordering i.e., physical ordering of
records in storage. Also the file organization determiners the set of operations necessary
to find particular records (i.e., Access method is the way the records is accessed (read)
from a file.

File organization represents the arrangement of the records within a file whereas Data
organization represents arrangement of data within a record.

Sequential file

The most basic way to organize records in a fie is to use sequential organization in this
organization, records are written consecutively when either a file is created or a record in
inserted in it. At the time of accessing the records are accessed in the same order as they
were inserted (serial access) i.e. accessing follows FIFO (First out) technique. For
instance if a stores 800 records and a record number 730 is to be accessed then first 729
records must be read one by one in order to read 730th record.

The records of a sequential file are ordered by the value of some field in each record.
Such a file is called sorted file and field (s) which determiners the order of records n
know as sort key.
A file may be sorted in ascending or descending order by the value of a sort key which
might be composed of one or more fields. For example a file employee file (empno,
empname, desig, dept, basic pay grade) may be sorted on empno, then empno becomes its
sort key.

A file, in which records are accessed in the same order as they were written in but there is
no importance in the key field i.e. file is not arranged in a particular is called serial file
and organization is referred to as serial organization.

Storage media for sequential file

For storing the sequential file the storing medium should be such that it can support the
very nature of the sequential files i.e., it should be able to provide the serial access.
Sequential organization suits electromagnetic devices like tapes, which are sequential by
nature or disk devices which are capable of sequential operation.

In practice, sequential files are by nature or for application which need to access its
records serially e.g. in an organization to prepare the pay slips of all its employees, it
needs to access all records if employee file one by one (serially) in order to get data for
pay slips.

File operations on a sequential files

Before any file operation is performed in a sequential file the, its processing determine
the appropriate order for sorting the records of a sequential file e.g. to generate pages’ of
a telephone directory, the information should be ordered by the subscriber’s last name
and first name. Therefore before performing any operation on a file its processing
requirements must be determined.

CREATION of a sequential file

The creation of a sequential file involves the creation of records in the required order
(sequence) into an appropriate storage medium (which support sequential organization).
The creation of sequential file involved tasks of

i) Collecting data
ii) Converting data into machine readable form
iii) Validating (to avoid incorrect data) the datra,
iv) Correcting rejected data
v) Sorting (arranging data in a particular order) data.

Step (iii) and (iv) are very important steps as these to ensure the correctness of the input
data. Validation involves the verification procedure to check that the data values being
entered are actually the same as that of original values and no data values are missed.
Validation might include following types of checks:

(a) Data value must be within a proper range e.g. in a date


(dd/mm/yy) dd must be within 1-31; mm must fall within 1-12,
etc.; similary; sex must be either M or F.
(b) Presence of required fields, e.g., empno must be present for an
employee record.
(c) Proper types of values e.g., a numeric field cannot contain
alphabets.
(d) Check sums e.g., total number of input record must be equal to
total number of records on paper.
UPDATION of sequential file

Updation may involve insertion, modification deletion of record (s) of a file. A master
file is updated time to time in order to reflect the latest status. A master file represents a
static view of some aspect of a organizations business. However most aspects of an
organization's business keep on changing; for instance, employee status changes when
employees are hired or fired; products status changes when prices are revised or quantity-
on-hand changes. These changes must be incorpated into master file in order to make it
reflect accurately the state of an organization.

A Master file can either be updated interactively i.e. as soon as need arises for master file
updation, it is updated there and then, or in batch updation manner in which transaction
(change which are going to be applied to master file) are collected and are periodically
applied, to update master file.

Frequency of master file updates

The frequency at which master file should be updated depends upon several factors like:

(i) Rate of change of data. More frequently the data changes (i.e. transactions
occur), more frequently the master file will be updated.

(ii) Size of master file. Larger is the size of master file less frequently it will be
updated, as with

(iii) Urgency of need for current data on master file. More frequently is the
current data is required, more frequently master file will be updated.
(iv) File activity ratio.

A file activity ratio, may be defined as follows:


File activity ratio = Number of records read and used (No of transactions)
Number of records in master file

More is the file activity ratio more frequently the master file will be updated. If the file
activity ratio is less (say 20%), then master file will be updated after a gap of time (during
which the transaction occur), as the greater the length of time between master file
updates, the greater will be the file activity ratio.

STEPS IN BATCH UPDATION

In batch updation, transactions are collected in form of a file and master file us
periodically updated using this transaction file by processing all transaction one by one.
If master file uses sequential organization, the transaction data should also be sorted in
the same order before processing. There can be three update operations viz insertion,
modification or deletion which are performed by checking transaction type field's value.

Update Logic

Since both the files the master file, the transaction file in the same order, all the operation
are performed by matching primary key's values of both files records. The update logic
is given below. One record is read from both the files their keys are matched and in case
of the matching keys, corresponding operations are (insertion,/modification/deletion) is
performed by checking the transaction record type.

While updating there could be two cases possible (i) a record in the master file has one
corresponding transaction record with the matching key value, and (ii) a record in the
master file has more than one transaction records with matching keys. The logic being
given below handles both mentioned cases. Every time after batch updation, new master
file is crated after incorporating the changes in the old master file. The record to be
inserted is written directly in the into the master file. The record to be modified is first
searched for in the old master, if found changes are incorporated in it and then written in
to the new master file. The record to be deleted is first searched for in the old master file,
if found is not copied on to the new master. The records of the old master, which do not
have any corresponding transaction are copied as they are, on to new master.

Batch updation algolithim

Create (NEWMASTER) /*allocate space for new file


Open (OLDMASTER, TRANSACTION, NEWMASTER)
Read (TRANSACTION, TRANSREC)
Read (OLDMASTER, OLDMAS-REC)
While not cof (TRANSACTION) and not cof (OLDMASTER) do
BEGIN
STOREKEY = TRANSKEY then
Begin
If TRANS-KEY <OLDMAS-KEY then
Begin
If TRAN-REC type = “ INSERT” then
Begin
NEWMAS-KEY = TRAN-KEY
/* move all details of TRANREC-KEY into NEWMAS-REC*/
write (NEW MASTER,NEWMAS-REC)
end
end
print “ERROR”!record does not exists!!”
end
If TRAN-KEY>OLDMAS-KEY then
Begin
NEWMAS-KEYOLDMAS-KEY THEN
Begin
NEWMAS-KEY=OLDMAS-KEY

/*move all details of OLDMAS-KEY into NEWMAS-REC*/


write (NEWMASTER, NEWMAS-REC)
end
if TRAN-KEY = OLDREC then
begin
if TRAN-REC-type =”MODIFY” then
begin /*TRAN-REC-TYPE=”MODIFY” then
REC to OLDMAS-REC*/
NEWMAS-KEY = OLDMAS-KEY
Write NEWMASTER, NEWMAS-REC)
End
end/*
end/*
read (TRNSCTION, RAN – REC)
If TRAN-KEY <> STOR-KEY then
Begin
Read (OLDMASTER, OLDMAS-REC)
End
End /* end of while*/
If eof (TRANSACTION) then
Begin
While not eof (OLDMASTER) do
begin
NEWMAS-KEY=OLDMAS-REC
/*move all details of OLDMAS-REC to NEWMAS-REC*/
write (NEWMASTER, NEWMAS-REC)
Read (OLDMASTER, OLDMAS-REC)
end
end
if eof (OLDMASTER) then
begin
while not eof (TRANSACTION) DO
begin
NEWMAS-KEY = TRAN-KEY
/*move all details of TRAN-REC to NEWMAS-REC/*
write (NEWMASTER, NEWMAS-REC)
read (TRANSACTION, TRAN-REC)
end
end
print “ERROR ! Record does not exists!!”
end
end
assumptions made in the above algorithin are:
OLDMAS-REC -oldmaster record
NEWMAS-REC -new master record
TRAN-REC -Transaction record
TRAN-KEY - Transaction’s primary key
OLDMAS-KEY -Old master’s primary key
NEWMAS-KEY -New master’s primary key
STOR-KEY -a temporary key.

SOFTWARE ORGANIZATION
The software has five sub-programs which are later connected to the main program in
which the main goal is achieved. The program are as follows:
-MENU.H.
-DB.H
-STRY.CPP

-TRY.CPP
-SUB.CPP
which are all included in main program PRJ.CPP.

MENU.H
In menu.h file has included functions which are called in main program to display the
instructions to the user how to use the software. The unction mainmenu0will display
following instructions.
WELCOME TO MINISTRY OF EDUCATION
HERE ARE THE LIST OF UNIVERSITIES
R. UNIVERSITY OF ROORKEE.
B. UNIVERSITY OF BANGALORE.
J. UNIVERSITY OF RAJASTANI.
ENTER YOUR CHOICE:
This will help the user to choose in which particular university is interested on.
Another function univermenu() will be called to enable the user to go in the right
direction within the university.
These are the instruction :
WELCOME TI THE UNIVERSITY MENU.
ADMISTRATION.
DEPARTMENT.
STUDENT ORGANISATION
ENTER YOUR CHOICE:
This will enable the user to go the direction he/she desires in the university level.
Another functions called will enable the user/search in administration, department student
organization and other sections in the university. Other functions are datamenu(),
editmenu(), esmenu()

DB.H
This sub-program just defines constants which will be used in the main program. These
are FNAME_SIZE,NAME_SIZE.

STRY.CPP,TRY.CPP AND SUB.CPP

All these sub-programs do the same job in the main program of Adding data in the file,
Deleting data from the file, Modifying data in the program, Searching the required data
from the program. In the respective sub-programs there classes which are used to enable
the main program to do all the editing like adding to file, deleting from file, modifying
data in the file searching any data in the file etc..

FILES
Files which are dealt with are STUDENTS files of different departments and different
classes, FACULTY_MEMBERS files of different departments, ADMINISTRATION
files, STUDENT_ORGANISATION files and UNIVERSITY files which are called
respectively with the execution of the program.

TOOLS USED

The language used in designing this program is TURBO++ which is rather flexible and
useful in different applications. T is powerful modern language that combines the power,
elegance and flexibility of C and the features of objected-oriented programming. With its
object-oriented capabilities such as data abstaction, inheritence and polymorphism, C++
offers significant software engineering benefits over C.Programming pandits expect that
C++ will replace C as a general-purpose programming language. C++ is the language of
the future.
5 : CONCLUSION:

Object oriented systems are useful in modeling many real world situations in which real
objects can be put in one to one correspondence with program classes and objects.

In object – orented systems there is a simplicity in structure because almost every thing is
an object. In the object paradigm, systems become individual, self -. Contained units that
exhibit a certain behaviour of their own and interact with other objects only through the
passing of messages (calling members functions). Tasks get performed when a message
is sent to an object that can perform the task. Al the details of the task are rightfully
hidden from other objects.
6 : REFERENCES

* C++ The Complete Reference


By : Herbert Schildt.

* Turbo C++
By : Robert Lafore
Galgotia

* Designing Object – Oriented Software


By :Rebbeca Wirfs - Brock
: Brian Wilverson
: Lavren Wienera

* An Introduction to Database System


By : C.J. Dage

* C++ Primer Plus By : Stephene Prata,


FILE NAME : MENU. CPP
#include <iostream.h>
#include <conio.h>
#include <string.h>
#ifndef menu_h
#define menu_h
void mainmenu()
{
gotoxy(35,4);
cout < < “\n WELCOME TO MINISTRY OF EDUCATION.”;
gotoxy (35,5); * * * * * * * * * * * * * * * * * * * * * * * * *
gotoxy (35,4);
cout < < “\n\n HERE ARE THE LIST OF UNIVERSITIES “;
gotoxy (35,5); * * * * * * * * * * * * * * * * * * * * * * * *
cout < < “\n
cout < < “R. UNIVERSITY OF ROORKEE. \n\r”;
cout < < “B. UNIVERSITY OF BANGALORE. \n\r”;
cout < < “ T. TO QUIT. \n\n\n\r
ENTER YOUR CHOICE: “;
}
void univermenu()
{
gotoxy (35,4);
cout < < “\n WELCOME TO UNIVERSITY MENU. “;
goto x y (35,5);
cout < < “\n * * * * * * * * * * * * * * * * * * * * * * * *
cout < < “n\r\ \n\r
cout < < “A. ADMINISTRATION. \n\r”;
cout < < “D. DEPARTMENT. \n\r”;
cout < < “O. STUDENT ORGANISATION. \n\r “;
cout << “U. TO QUIT. \n\n\n\r\
ENTER YOUR CHOICE: “;
}
void totalmenu ()
{
gotoxy (35,4);
cout << “\n\r \n\r”;
cout < < “d. DATA ENTRY. \n\r”;
cout < < “N. EDIT. \n\r”;
cout < < “T. QUIT!. \n\n\n\r
ENTER YOUR CHOICE”;
}
void datamenu ()
{
clrscr();
gotoxy (35,4);
cout < < “ DATA ENTRY “;
gotoxy (35,5);
cout < < “ * * * * * * * * * * * * * * * *”;
cout < < “\n\r\
\n\r
E. E &C . \n\r\
C. CST . \n\r\
L. ELECTRICAL . \n\r\
M. MECHANICAL . \n\r\
V. CIVIL . \n\r\
H. CHEMICAL .\n\r”
< >”Q. QUIT. \n\n\n\r\
ENTER YOUR CHOICE:”;
}
void editmenu()
{
clrscr();
gotoxy(39,4);
cout << “EDT”;
gotoxy (39,5);
cout << “\n\r\
\n\r
A. ADDITION. \n\nr\
D. DELECTION. \n\r\
I. MODIFICATION. \n\r\
U. UPDATION.\n\r
K. QUIT.\n\n\n\r\
ENTER YOUR CHOICE:”;
}
void teachers()
{
clrscr();
gotoxy(39,4);
cout <<” TEACHING STAFF “;
gotoxy (39,5);
cout < < “ * * * * * * * * * * * * * * * * * * * * * * * * * * *
cout < < “\n\r”;
cout << “\n\r”;
cout < < “F. 1st Year. \n\r”;
cout < < “S. 2nd Year . \n\r
cout < < .T. 3rd Year. \n\r”;
cout < < “L. 4th Year. \n\r:
cout < < “Q. TO QUIT !.\n\n\n\r\
ENTER YOUR CHOICE: “;
}
void students()
{
clscr();
gotoxy (39,4);
cout < < “ STUDENTS “’
gotoxy (39,5);
cout < < “ * * * * * * * * * * * * * “;
cout < < “ \n\r”;
cout < < “\n\r”;
cout < < “F. 1st Year .\n\r”;
cout < < “S. 2nd Year .\n\r”;
cout < < “T. 3rd Year .\n\r”
cout < < “L. 4th Year . \n\r”;
cout < < “Q. QUIT!.\n\n\n\r\
ENTER YOUR CHOICE:”;

}
void subjects()
clrscr();
gotoxy (39,4);
cout << “SUBJECTS \n”;
gotoxy (39,5);
cout < < “ * * * ** * * * * * * *
cout < < “\n\r”;
cout < < “\n\r”;
}
void esmenu()
{
clrscr ();
gotoxy (39,4);
cout < < “EDITING OPTION”;
gotoxy (39,5);
cout < < “ * * * * ** * * ** * * * * * * *
cout < <” \n\r
\n\r
E. E & C . \n\r\
C. CST . \n\r
L. ELECTRICAL . \n\r\
M. MECHANICAL . \n\r\
V. CIVIL .\n\r\
H. CHEMICAL. \n\r\
Q. EXIT. \n\n\n\r
ENTER YOUR CHOICE:”;
}
#endif
FILE NAME: DB. CPP

#ifndef DB_H // Prevent multiple includes


#define DB_H // Define symbol for possible next time

#ifndef TIME_H // Check if time .h already included


#include <time.h> // if not. Include the header
#endif // End time.h include directives
15Xof

// -----------------------------------------------------------------
// String field lengths (including punctuation and null term)
// ------------------------------------------------------------------

#define FNAME_SIZE 81
#define NAME_SIZE 41

// -----------------------------------------------------------------------
// Miscellaneous type definitions
// -----------------------------------------------------------------------

typedef enum {FALSE, TRUE} Boolean;

#endif
FILE NAME : MAIN.CPP

#include”try.cpp”
#include “menu.cpp”
#include< iostream.h>
#include<conio.h>
#incude<stdio.h>
#include<string.h>
#include<ctype.h>
#include”stry.cpp”
#include”sub.cpp”

int Getmenuselection()
{
fflush(stdin);
int c = toupper (getchar ());
fflush(stdin);
return c;
}
void main ()
{
Boolean done = FALSE;
Int selection;
Clrscr();
While(!done)
{
mainmenu();
selection = Getmenuselection();
switch (selection)
{
case ‘R’
{
clrscr( );
Boolean r1 = FALSE;
Int r;
Crlscr( );
While(!r1)
{
univermenu( );
r = Getmenuselection( );
switch (r)
{
case ‘D’
{
clrscr( );
Boolean l1 = FALSE;
Int l;
Clrscr( );
While(!l1)
{
totalmenu( );
l = Getmenuselection( );
switch (l)
{
case ‘D’
{
clrscr();

Boolean d1 = FALSE
Int d;
Clrscr( );
While(!d1)
{
datamenu( );
d=Getmenuselection( );
switch (d)
{
case ‘E’:
{cout <<”\nEntry to E&C deptt.”;
cout<<”\nPress enter to continue!.”;
getch ( );
clrscr( );
Boolean e1 = FALSE;
Int e;
char c;
clrscr ( );
while (!e1)
{
cout < < “\n\tWanna see teacgers or studenetns (t/s)?: “;
cin > > c;
if (c = = ‘t’)
{
getch ();
clrscr ();
boolean t1 = FALSE;
int t;
clrscr ();
while (!t1)
{

teachers( );
t = Getmenuselection( );
switch(t)
{
case ‘T’
{cout << “\3rd Year. ‘;
Psee( );
clrscr( )’}
break ;
case ‘Q’:
{
t1 = TRUE;
cout << “nExiting! “;
clrscr( );
}
break;

}
} }
else if (c = = ‘s’)
{
getch( );
Clrscr( );
Boolean s1 = FALSE;
int s ;
clrscr( );
while (!s1)
{
students ( );
s = Getmenuselection ( );
switch (s)
{
case ‘T’:
{
{
cout < < \3rd Year.”;
SSee ( );
//clrscr ( );
}
getch ( );
clrscr( );
Boolean z1 = FALSE;
clrscr ();
while (!z1)
{
subjects ( );
SBSee( );
Clrscr ( );
}
}
break;

case “Q”;
{
s1 = TRUE,
cout < < “\nxiting!”
clrscr ( );
}
}
}
clrscr ( );
}
}
/*e = Getmenuselection ( );
switch (e)
{
case ‘T’:
{cout < < “\N3rd Year.”;
getch ( );
clrscr ( );
Boolean e2 = FALSE;
Int f;
clrscr ( );
while (!e2)
{
subjects ( );
f = Getmenuselection ( );
switch (f)
{
case ‘T’:
{cout < < “\n3rd Year”;
getch ( );

clrscr ( );
SBSee ( );}
break;
case ‘K’
{e2 = TRUE;
cout < < “\nQuiting”;}
break; }}}}*/
break;
case ‘C’
{
cout << “\nEntry to CST deptt”;
getch ( );
clrscr ( );
}
break;
case ‘L’
{
cout < < “\nEntry to ELECTRICAL deptt”;
getch ( );
clrscr ( )
}
break;
case ‘M’
{
cout < < “\nEntry to Mechanical deptt”;
getch ( );
clrscr ( );
}
break;
case ‘V’:
{
cout < < “\nEntry to CIVIL deptt”;
getch ();
clrscr();
}
break;
Case ‘H’:
{
cout < < “\nEntry to CHEMICAL deptt”;
getch();
clrscr();
}
break;
case ‘Q’:
{
d1 = TRUE;
cout < < “\nQuit from data menu”;
clrscr ( );
}
break;
default:
cout < < “\nError in data menu”;
break;
}
}
clrscr ( ) ;
}
break;

case ‘N’
{
clrscr( );
Boolean e1 = FALSE;
Int e;
clrscr ( );
while (!e1)
{

editmenu ( );
e = Getmenuselection ( );
switch (e)
{
case ‘A’:
{
cout < <” ………….. addition\n\n”;
getch ( );
clrscr ( );
Boolean e2 = FALSE;
int ea;
clrscr ( );
while (!e2)
{
esmenu ( );
ea = Getmenuselection ( );
switch (ea)
{
case ‘C’:
{
cout < < “\nAddition in CST”;
getch ( );
clrscr ( );
}
break;
case ‘L’
cout < < “\nAddition in ELECTRICAL”;
getch ( );
clrscr ( );
}
break;
case ‘E’ :
{
cout <<”\nAddition in E&C”;
getch ( );
clrscr ( );
Boolean a1 = FALSE;
int a;
char ch;
clscr ( );
while (!a1)
{
cout << “\nWanna add in teachers or students or subjects”
<<” (t/s)?: “;
cin >> ch;
if (ch = = ‘t’)

{
getch ( );
clrscr ( );
boolean t1 – FALSE
int t;
clrscr ( );
while (!t1)
{
teachers ( );
t = Getmenuselection ( );
switch (t)
{
case ‘T’:
{
cout << “\n3rd Year. :;
PSee ( );
Clsrscr( );
}
break;
case ‘Q’
{
t1 = TRUE;
cout << “Exiting!.”;
clrscr ( );
}
break;
}
}
}
else if (ch = = ‘s’)
{
getch ( );
clrscr ( );
Boolean s1 = FALSE
int s;
clrscr();
while (!s1)
{
students ( );
s = Getmenuselection ( );
switch (s)
{
case ‘T’
{
cout << “n3rd Year. “;
SSee ( );
SBSee ( );
clrscr ( );
}
break;
case ‘ Q’
{
s1 = TRUE;
cout << “\nExiting!.”;
clrscr ( );
}
break;

}
}
}
}
}
break;
case
cout << “ …………………. Deletion.\n”;
getch ( );
clrscr ( );
Boolean e3 = FALSE;
Int ed;
clrscr ( );
while ( e3)
{
esmenu( );
ed = Getmenuselection( );
switch(ed)
{
case ‘C’:
{
cout << “\nDeletion in CST”;
getch( );
clrscr( );
}
break;
case ‘L’:
{
cout <<”\nDeletion in ELECTRICAL”;
getch( );
clrscr( );
}
break;
case ‘E’:
{
cout <<”\nDeletion in E&C”;
getch ( )
clrscr( );
Boolean y1 = FALSE;
int y;
char c;
clsrcr ( );
while (!y1)
{
cout << “\nTeachers or students(t/s):”;
cin >> c;
if(c= =’t’)
{
getch( );
clrscr( );
Boolean t1 = FALSE;
int t;
clrscr( )1
while (!t1)
{
teachers( );
t = Getmenuselection( );
switch(t)
{
case ‘T’
{
cout < < “\n 3rd Year.”;
PDel( );
clrscr( );
}
break;
case ‘Q’:
{
t1 = TRUE;
cout < < “\nExiting.”;
clrscr( );
}
break;
}
}
}
if(c = = ‘s’
{
getch( );
clrscr( );
Boolean s1 = FALSE;
int s;
clrscr( );
while(!s1)
{
students( );
s = getmenuselection( );
switch(s)
{
case ‘T’
{
cout < < “\n3rd Year.”;
SDell( );
SBDel( );
clrscr( );
}
break;
case ‘Q’:
{
s1 = TRUE;
cout < < “n\Exiting!”;
clrscr( );
}
break;
}
}
}
}

break;
case ‘M’:
{
cout <<”Delection in MECHANICAL”;
getch( );
clsrcr( );
}
break;
case ‘V’:
{
cout < < “Deleion in CIVIL “;
getch ( );
clrscr( );
}
break;
case ‘Q’:
{
e3 = TRUE
cout < < “Exit from del menu!”;
clrscr( );
}
break;
default:
cout < < ‘Error in del menu!”;
break;
}
}
clrscr( );
}
break;
case ‘I’
{
cout < < “………………. modification.\n”;
getch ( );
clrscr( )
Boolean e4 = FALSE;
int em;
clrscr ( );
while ( !e4)
{
esmenu ( );
em=Getmenuselection ( );
switch (em)
{
case ‘C’:
{
cout < < “Modification
getch ( );
clrscr ( );
}
break;
case ‘L’
cout < < “Modification in ELECTRICAL”;
getch ( );
clrscr( );
}
break;
case ‘ E’:
{
cout < < “\nModification in E &C.”;
getch ( );

clrscr ( );
Boolean f1 = FALSE;
int f;
char c;
clrscr ( );
while (!f 1)
{
cout < < “\nTeachers or students (t/s)?:”;
cin > > c;
{
getch ( );
clrscr ( );
Boolean t1 = FALSE;
int t;
clrscr ( );
while (!t1)
{
teachers ( );
t = Getmenuselection ( );
switch (t)
{
case ‘T’
{
cout < < “\n 3rd Year. “;
PMod ( );
clrscr ( );
}
break ( );
case ‘Q’:
{
t1 = TRUE;
cout < < “\nExiting!.”;
clrscr ( );
}
break;
}
}
}
if(c = = ‘S’)
{
getch ( );
clrscr ( );
Boolean s1 = FALSE;
int s;
clrscr ( );
while (!s1)
{
students ( );
s = Getmenusection ( );
switch(s)
{
case ‘T’
{
cout < < “\n 3rd Year. “;
SMod ( );
SBMod ( );
clrscr ( );
}
break;
case ‘Q’
{
s1 = TRUE;
cout < < “\nExiting!”;
clrscr ( );
}
break;
}
}
}
}
}

break;
case ‘M’:
{
cout < < “Modification in MECHANICAL “;
getch ( );
clrscr ( );
}
break;
case ‘V’:
{
cout < < “Modification in CIVIL “;
getch ( );
clrscr ( );
}
break
case ‘Q’:
{
e4 = TRUE;
cout < < “Exit from mod menu!”;
clrscr ( );
}
break;
default:
cout < < “Error in mod menu!”;
break;
}
}
clrscr ( );
}
break ;
case ‘U’:
{
cout < < “Updation”;
getch ( );
clrscr ( );
}
break;
case ‘K’:
{
e1 = TRUE;
cout < < “Exit from edit menu!”;
clrscr ( );
}
break;
}
}
clrscr ( );
}
}
}
}
break;
case ‘T’:
{
r1 = TRUE;
cout < < “\nExit from university menu!”;
clrscr ( );
}
break;

}
}
clrscr ( );
}
break;
case ‘T’:
{
done = TRUE;
cout < < “\nExit from main menu!”;
clrscr ( );
}
break;
}
}
}
FILE NAME : STRY.CPP

#include <iostream.h>
#include <fstream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
#include “db.h”
#include ptry_cpp.h
#define ptry_cpp

class professor
{

public Tcode,n;
char name{NAME_SIZE};
int subcode {4};
void getdata (int );
void putdata ( );

};
void professor::getdata (int c)
{
int ct, b1 , d1, c1, d2, b2;
clrscr ( );
cout < < “\n\tDATA ENTRY IN FILE.”;
cout < < “\n\t * * * * * * * * * * * * * * * * * * *”;
cout < < “\n\nEnter name:”;
cin > > name;
cout < < “\nEnter teacher’s code: “;
cin > > = c;
cout < < “\nHow many subjects?;
cin > > n;
cout < < n;
cout < < “\nEnter subjects codes : ;
for (int i = 0; i < n; i + + )
{
cout < < “\n” < < i + i < < “ : “ ;
cin > > subcode (i);
}
I1:;
gotoxy(30,7);
cin.getline(name,NAME_SIZE);
d 1 = strlen (name);
for( ct = 0 ; ct < d 1 ; ct + + )
{
b 1 = toascii(name{ct});
if (b1 < 3 1 | | (b 1 > 33 && b1 <(65) | | (b1 >90 && b1 <1 <97) | | (b1 > 122 && b1 < =
{
cout < < b1;
gotoxy (12, 20);
cout < < “Special Characters or Integers not Allowed. Re-enter the First Name.”;
gotoxy (12, 21);
cout < < “ Wait….. “;
sleep (2);
gotoxy (12, 20);
cout < <”
gotoxy (12, 21);

cout < < “


gotoxy (30, 7);
cout < < “
goto I1;
}
}
cin.ignore ( );
}

void professor : : putdata ( )


{
cout < < “\nName: “ < < name;
cout < < “\nTeacher’s code
infile.seekg (O,ios : :end);
int endposition = infile.tellg ( );
int n = endposition/sizeof (p);
infile.close( );
return n;
}

void tool : :insert (char *file)


{
char ch = ‘n’;
cout < < file;
getch ( );
int code 1;
professor p ;
tool c;
code 1 = c.countrec (file);
fstream profile;
profile.open(file,|ios::in|ios::out|ios::binary|ios::app);
code 1 ++;
do
{
Tcode = code ++;
p.getdata(code);
profile.write ( (char*)&p,sizeof(p) ) < < flush;
gotoxy(30,13);
cout < < “\nWanna more record(y/n)?: “;
cin > > ch;
}
while(ch = = ‘y’);
profile.close( );
}

void tool::showpar(char *file)


{
clrscr ( );
char ch = ‘n’;
int cde,t;
tool c;
professor p;

t = c.countrec(file);
ifstream infile;

infile.open(file,ios::nocreate);
if(!infile)return;
do
{
cout < < “\nEnter professor code you would like to see: “;
cin > >dce;
if (cde > t)
{cout < <”\nNo data exists with this code!TRY AGAIN.”;}
else
{
int position = (cde-1)*sizeof(professor);
infile.seekg(position);
infile.read( (char *)&p, sizeof(p) );
p.putdata ( );
}
cout < < “\nWant to see more record(y/n)?: “;
cin > > ch;
}
while (ch = = ‘y’);
infile.close ( );
}
voild tool : : showall(char *file)
{
clrscr ( );
tool c;
professor p;

int t = c.countrec (file);


cout < < t;
getch ( );
ifstream infile;
infile.open (file,ios::nocreate);
if (!infile)return;
infile.seekg(0);
gotoxy(1,1);
cout < <endl;
infile.read ( (char*)&p, sizeof (p) );
while(!infile.eof() )
{
p.putdata ();
cout < < endl;
infile.read ( (char*)&p, sizeof(p) );
}
infile.close ( );
getch ( );
}

void tool::getcode(int c)
{
Tcode = c;
}

void tool::del(char*file)
{
clrscr ( );
tool c;

professor p;
//char ch;
int I, cde,t;
char ch;
do
{
cout < < “\nEnter code to delete:”;
cin > > cde;
t = c.countrec(file);
ifstream infile;
ofstream outfile;
infile.open (file,ois::nocreate);
if(!infile)return;
outfile.open(“temp.dbf”);
if(cde= =1)
{
goto again;
}
for(i=1;i<cde;i+ +)
{
int position = (i-1)*sizeof(professor);
infile.seekg(position);
infile.read( (char *)&p, sizeof(p) );
outfile.write( (char *)&p,sizeof(p) );
}
again:;
for (i = cde + 1;i + +)
{
int position = (i-1) *sizeof(professor);
infile.seekg(position);
infile.read( (char *)&p,sizeof(p) );
c.getcode(i-1);
outfile.write ( (char *)&p,sizeof(p) );
}
infile.close ( );
outline.close ( );
remove (file);
rename(“temp.dbf”,file);
cout < < “\n want to delete more record”;
cin > > ch;
}
while(ch = =’y’);
}

void tool::mod(char *file)


{
clrscr (char *file)
{
clrscr ( );
tool c;
professor p;
int cde,t;
t = c.countrec(file);
cout < < “\nEnter code to modify: “;
cin > > cde;
if (cde > t)
{
cout < < “cannot modify this record “;
return;

}
Else
{
fstream proffile;
profile.open (file,ios::out|ios::binary);
int position = (cde-1) *sizeof(professor);
if(profile.seekp(position);
c.getdata(cde);
profile.write( (char *)&p,sizeof(p) )< <flush;

profile.close( );
}
}
int tool::comp(char nl])
{
if (strcmpi(n,name) = = 0)
return 1;
else
return 0;
}

void tool::find(char *file)


{
tool c;
professor p;
char n{NAME_SIZE};
cout < < “\nEnter name to search:”;
cin.ignore ( );
cin.getline[n,NAME_SIZE];
ifstream infile ;
infile.open(file,ios::nocreate);
if(!infile)return;
while(!infile.eof(p) );
{
infile.read( (char *)&p,sizeof(p) );

if(c.comp(n)) [p.putdata ();]//showdata();}


}
infile.close();
}

void Psee()
{
tool t;
char file [FNAME_SIZE];

cout < < “\nEnter file name: “;


cin > > file ;
t.insert (file);
t.showpar(file);
t.showall(file);
}
void PDel()
{
tool t;

char file[FNAME_SIZE];
char ch;

cout < < “\nWanna to delete any data (y/n):”;


cin > > ch;
if (ch = = ‘y’)
{
cout < < “\nEnter file name: “;
cin > > file;
t.del(file);
t.showall(file);
}
}
void PMod()
{
tool t;
char file [FNAME_SIZE];
char ch;

cout < < “\nWanna modify any data (y/n)?: “;


cin > > ch file;
if(ch = = ‘y’)
{
cout < < “ \nEnter file name:”;
cin > > file ;
t.mod(file);
t.showall(file);
}
void PSearch ( )
{
tool t;
char file [FNAME_SIZE]
char c, ch;
cout < < “\nWanna search any data (y/n): “;
cin > > ch;
if(ch = = ‘y’)
{
cout < < “\nEnter file name: “;
do
{
t.find (file);
cout < < “\nSearch more (more(y/n): “;
cin > > c;
}
while(c = = ‘y’);
}
#endif

FILE NAME :TRY.CPP

#include < iostrem.h >


#include < fstream.h >
#include < conio.h >
#include < studio.h >
#include < string.h >
#include < ctype.h >
#include < dos.h >
#include “db.h”
#ifndef stry _ cpp
#define stry _ cpp

class student
{

public:
long Rollno;
int n;
char name [NAME_SIZE];
int Yr;
void getdata (long );
void putdata ( );

};
void student::getdata(along c)
{
int ct. b1, d1, c1, d2, b2;
clrscr ( );
cout < < “\n\Tdata entry in file.”;
cout < < “\n\t * * * * * * * * * * ** * * * * * * * *”;
cout < < “\n\nEnter name: “;
cin > > name;
cout < < “\nEnter student’s Roll number: “;
cin > > Rollno;
rollno = c;
I1:;
gotoxy (30,7);
cin.getline(name,NAME_SIZE);
d1 = strlen(name);
for( ct = 0;ct<d1 ;ct + +) {
b1 = toascii(name[ct]);
if( b1 < 31 | | (b1 >33 && b1 < 65) | | (b1> 90 && b1 <97) | | (b1>122 &&
b1 < = 254))
{

cout < < b1;


gotoxy(12, 20);
cout < < “Special Characters or Integers not Allowed. Re-enter the First
name. “;
gotoxy (12, 21);
cout < < “Wait….”;
sleep (?);
gotoxy(12, 20);
cout < <”
“;

gotoxy (12, 21);


cout < <”
gotoxy (30, 7);
goto I1;
}

}
cin.ignore ( );
}

void student::putdata ( )
{

cout < < “\nName: “< < name;


cout < < “\nStudent’s Rollno: < < Rollno;
getch ( );
}
class tull : virtual public student
{
protected:
int code;
public:
void getcode(long c);
void showpar (char *file);
void sowall (char *file);
long countrec (char *file);
void insert (char *file);
void del(char *file);
void mod (char *file);
void find(char *file);
int comp (char n[]);
};
long tull::countrec (char *file)
{
student s;
ifstream infile;
infile.open (file,ios::nocreate);
if(!infile)return 0;
infile.seekg(0,ios::end);
int endposition = infile.tellg( );
int n = endposition/sizeof (s);
infile.close ( );
return n;
}
void till::insert(char *file)
{
char ch = ‘n’;
cout < < file;
getch ();
long code1;
student s;
tull c;
code 1 = c.countrec(file);
fstream proffile;
profile.open (file,ios::in|ios::out|ois::binary|ios::app);

code 1 + +;
do
{
Rollno = code 1 + +;
s.getdata(code);
profile.write( *)&s,sizeof(s) < <flush;
gotoxy(30,13);
cout < < “\nWanna more record(y/n)?: “;
cin > > ch;
}
while(ch = = ‘y’);
profile.close ( );
}

void tull::showpar(char *file)


{
clrscr ( );
char ch = ‘n’;
int cde,t;
tull c;
student s;

t = c.countrec(file);
ifstream infile;
infile.open(file,ios::nocreate);
if(linfile)return;
do
{
cout < < “\nEnter student code you would like to see: “;
cin > > cde;
if(cde > t)
{cout < < “\nNo data exists with this code!TRY AGAIN.”;
else
{
int position = (cde-1)*sizeof (student);
infile.seekg(position);
infile.read( (char *)&s, sizeof(s) );
s.putdata( );
}
cout < <”\nWant to see more record (y/n)?: “;
cin > > ch;
}
while (ch = = ‘y’);
infile.close ( );
}

void tull::showall(char *file)


{
clrscr(
tull c;
student s;

int t = c.countrec(file);
cout < < t;
ifstream infile;
infile.open(infile,ios::nocreate);
if(!infile)return;
infile.seekg(0);
gotoxy(1,1);
cout < <endI;

infile.read( (char *)&s, size(s) );


while(!infile.eof() )
{
s.putdata( );
cout < < endl;
infile.close( );
getch( );
}
infile.close ( );
getch ( );
}

void tull::getcode(long c)
{
Rollno = c;
}

void tull::del(char *file)


{
clrscr ( );
tull c;
student s;
int I,cde,t;
char ch;
do
{
cout < < “\nEnter code to delete: “;
cin > >cde;
t=c.countrec(file);
ifstream infile;
ofstream outfile;
nfile.open(file,ios::nocreate);
f(!infile)return;
outfile.open(“temp.dbf”);
if(cde = = 1){
goto again;
}
for(i = 1;i <cde;i + +)
{
int position = (i-1)*sizeof(student);
infile.seekg(position);
infile.read( (char *)&s, sizeof(s) );
outfile.write(char *)&s,sizeof(s) );
}
again:;
for (i = cde +1;i < = t;i + +)
{
int position = (i-1) *sizeof(student);
infile.seekg(position);
infile.read( (char *)&s,sizeof(s) );
c.getcode(i-1);
outfile.write( (char *)&s,sizeof(s) );
}
infile.close( );
outfile.close ( );
remove(file);
rename(“temp.dbf”,file);
cout < < “\nWant to delete more record/n)?: “;

cin > > ch;


while(ch = = ‘y’);
}
void tull::mod(char *file)
{
clrscr ( );
tull c;
student s;
int cde,t;
t = c.countrec(file);
cout < < “\nEnter code to modify: “;
cin > > cde;
if(cde>t) {cout < < “\nCan’t modify this record! “;return;}
else
{
stream profile;
profile.open (file,ios::in|ios::out|ios::binary);
int position = (cde-1) *sizeof(student);
if(profile.eof())profile.clear();
profile.seekp(position);
c.getdata(cde);
profile.write( (char *)&s,sizeof(s) ) < < flush;

profile.close( );
}

}
int tull::comp(char n[])
{
if(strcmpi(n,name) = = 0)
return 1;
else
return 0;
}

void tull::find(char *file)


{
tull c;
student s;
char n [NAME_SIZE];
cout < < “\nEnter name to search:”;
cin.ignore ( );
cin.getline(n,NAME_SIZE);
Ifstream infile ;
infile.open(file,ios::nocreate);
if(!infile)return;
infile.read( (char *)&c,sizeof(c) );
while (!infile.eof())
{
infile.
cin > > file;
t.del(file);
t.showall(file);
}

}
void SMod( )
{
tull t;
char file [FNAME_SIZE];
char ch;
cout < < “\nWanna moodily any data (y/n)?: “;
cin > > ch;
if (ch = = ‘y’)
{
cout < < “\nEnter file name: “;
cin > > file;
t.mod(file);
t.showall(file);
}
}
void SSearch( )
{
tull t;
char file [FNAME_SIZE];
char ch,c;

cout < < “\nWanna search any data (y/n)?: “;


cin > > ch;
if (ch = = ‘y’)
{
cout < < “\nEnter file name: “;
cin > > file;
do
{
t.find (file);
cout < < “nSearch more (y/n)?: ‘;
cin > > c;
}
while (c = = ‘y);
}
}

#endif
FILE NAME : SUB.CPP

#include <iostream.h>
#include <fstream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
#include “db.h”
#ifndef sub_cpp
#define sub_cpp

class subject
{

public:
int n;
int subcode [10];

};
void subject::getdata()
{

//int ct,b1,d1,c1,d2,b2;
int n;
clrscr();
//gotoxy(28,2);
cout < <”\n\tDATA ENTRY IN FILE.”;
//gotoxy (28,3);
cout < < “\n\t * * * * * * * * * * * * * * * * *”;
//gotoxy(30,5);
cout < < “\n\nHow many subjects?: “;
cin > > n;
for (int j = 0; < n; j + +)
cin > > subcode[j];

}
void subject::putdata()
{
for (int j = 0; j < 10; j + +)
{
cout < < j + 1 < <” : “;
cout < < “\nSubject code: “ < < subcode [j];
}

class tul : virtual public subject


{
protected:
int code;

public:

void getcode (int c);


void showpar (char *file);
void showall(char *file);
long countrec (char *file);
void insert(char *file);
void del(char *file);
void mod(char *file);
void find(char *file);
int comp n[]);
};

long tul::countrec(char *file)


{
subject b;
ifstream infile;
infile.open(file,ios::nocreate);
if(!infile)return 0;
infile.seekposition = infile.tellg();
int n = endposition/sizeof(b);
infile.close();
return n;
}

void tul::onsert(char *file)


{
char ch =’n’;
cout < < file;
getch();
int code 1;
subject b;
tul c;
code 1 = c.countrec(file);
fstream subfile;
subfile.open(file,ios::in|ios::out|ios::binary|ios::app);
code 1 + +;
do
{
b.getdata();
subfile.write( (char *)&b,sizeof(b) ) < < flush;
gotoxy(30,13);
cout < <”\nWanna more record(y/n)?: “;
cin > > ch;
}
while(ch = = ‘y’);
subfile.close();
}

void tul::showpar(char *file)


{
clrscr();
char ch = ‘n’;
int cde,t;
subject b;

t = c.countrec(file);
ifstream infile;
infile.open(file,ios::nocreate);

tul c;
subject b;
int I,cde,t;
char ch;
do
{
Cout < < “\nEnter code to delete: “;
Cin > > cde;
t = c.countrec(file);
ifstream infile;
ofstream outfile;
infile.open(file,ios::nocreate);
if(!infile)return;
outfile.open(“temp.dbf”);
if(cde = = 1){
goto again;
}
for (i = 1;i< cde; i + + )
{
int position = (i- i)sizeo(subject);
infile.read( (char *) &b, sizeof(b) );
outfile.write( (char *) &b,sizeof(b) );
}
again:;
for(i=cde + 1;i + + )
{
int position = (i – 1 ) * sizeof (subject);
infile.seekg(position);
infile.read( (char *) &b, sizeof(b) );
c.getcode(i-1);
outfile.write( (char * )&b,sizeof(b) );
}
infile.close( );
outfile.close( );
remove(file);
rename(“temp.dbf”,file);
cout < < “\nWant to delete more record(y/n)?: “;
cin > > ch;
}
while(ch = =’y’);
}

void tul::mod(char * file)


{
clrscr ( );
tul c;
subject b;
int cde,t;
t = c.countrec(file);
//char ch,ch1;
//do
//{
cout < < “\nEnter code to modify: “;
cin > > cde;
if(cde>t) {cout < < “\nCan’t modify this record! “;return;}
else

if (infile)return;
do
{
cout < < “ \nEnter subject code you would like to see: “;
cin > > cde;
if (cde > t)
{cout < <“\nNo data exists with this code!TRY AGAIN.”;}
else
{
int position = (cde-1) *sizeof(subject);
infile.seekg(position);
infile.read( char *)&b, sizeof(b) );
b.putdata();
}
cout < < “\nWant to see more record(y/n)?: “;
cin > > ch;
}
while(ch = = ‘y’);
infile.close();
}

void tul::showall(char *file)


{
clrscr();
tul c;
subject b;

int t = c.countrec (file);


cout < < t;
getch();
ifstream infile;
infile.open(file,ios::nocreate);
if(!infile)return;
infile.seekg(0);
gotoxy(1, 1);
cout < < end1;
infile.read ( (char *) &b, sizeof(b) );
while(!infile.eof() )
{
b.putdata();
cout < <endl;
infile.read( (char *)&b, sizeof(b) );
}
infile.close();
getch();
}

void tul::getcode(int c)
{
for (int j = 0; j < 10; j + + )
subcode[j] = c;

void tul::del(char *file)


{
clrscr( );
/* void SBSearch()
{
tul t;
char file NAME_SIZE];
char ch,c;

cout < < “\nWanna search any data(y/n): “;


cin > > ch;
if(ch = = ‘y’)
{
cout < < “\nEnter file name: “;
cin > > file;
do
{
t.find(file);
cout < < “\nSearch more (y/n)?: “;
cin > > c;
}
while(c = = ‘y);
}
}*/

#endif

{
fstream subfile;
subfile.open(file,ios::in|ios::out|ios::binary);
int position = (cde-1)*sizeof(subject);
if(subfile.eof( ) ) subfile.clear ( );
if(subfile.seekp(position)
c.getdata( );
subfile.write ( char *)&b,sizeof(b) < < flush;
subfile.close();
}

void SBee (void)


{
tul t;
char file [FNAME_SIZE];

cout < < “\nEnter file name: “;


cin > > file;
t.insert(file);
t.showpar (file);
t.showall(file);

}
void SBDel()
{
tul t;
char file [FNAME _SIZE]
char ch;

cout < < “\nWanna to delete any data(y/n)?:”;


cin > > ch;
if(ch = =’y)
{
Cout < < “\nEnter file name: “;
Cin > > file;
t.del(file);
t.showall(file);
}
}
Void SBMod()
{
Tul t;
Char file [FNAME_SIZE];
char ch;
cout < < “\nWanna modify any data(y/n)?: “;
cin > > ch;
if(ch = = ‘y)
{
cout < < “\nEnter file name: “;
cin > > file;
t.mod(file);
t.showall(file);
}
}

You might also like