hostel report 1

121
Beant College of Engineering & Technology Submitted To: Submitted By: Mr. Vikas Singla University Roll No: 6130302135 Paran Vijan College Roll No: 141/06

Upload: manav-mahajan

Post on 18-Apr-2015

45 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Hostel Report 1

Beant College of Engineering & Technology

Submitted To: Submitted By:

Mr. Vikas Singla

University Roll No: 6130302135

Paran Vijan

College Roll No: 141/06

University Roll No: 6130302136

Page 2: Hostel Report 1

DEPARTEMENT OF COMPUTER SCIENCE &

ENGINEERINGAcknowledgement

It would be inappropriate to call this report complete and successful if we, Pankaj

Arora and Paran Vijan, don’t thank the people who guided as in the preparation of this

project.

The submission of this report gives us an opportunity to convey gratitude to all

those who have helped us reached a stage from where we have immense confidence to

launch my career in the competitive world of Information Technology.

First and foremost, we would like to express my sincere gratitude and in depth to

my guide Mr. Vikas Singla, for his valuable help during the development of the project.

Without his suggestion and timely help I would not have been able to complete my

project. He has been a source of perpetual inspiration to us, gently guided and inspired

me towards the bright advice. It has been great pleasure to work with him who not only

spared his valuable time but also provided valuable guidance and unfailing timely help

during the entire course of my training.

I am highly thankful and grateful to all the teachers and staff members.

Yours Truly,

Paran Vijan

2

Page 3: Hostel Report 1

Table of Contents

PART 1[Project Report]

Hostel Management System

1. Introduction………………………………………..62. Description of the project .........…………………...83. Objectives of the project ………………………...114. Modules of the project…………………………...135. Working of the project

a. Flow Diagram…………………………………276. Snapshots/Results………………………………..347. Conclusion

a. Improvements……………….………………...398. Appendices

a. Source-Code of the program……..……………419. References………………………………………..76

3

Page 4: Hostel Report 1

PART II [Seminar Report]

System Analysis & Design

1. Introductiona. System…………………………………………79

2. System Life Cyclea. Diagram………………………………………..80

3. Approaches to System developmenta. Process-Oriented Approach…………………...81b. Object-Oriented Approach…………………….81

4. Phases of System Development Life Cycle [SDLC]a. System study…………………………………..82b. Feasibility Study………………………………82c. System Analysis……………………………….82d. System Design………………………………...83e. Coding…………………………………………84f. Testing…………………………………………84g. Implementation………………………………..85h. Maintenance…...………………………………85

5. Alternatives to SDLCa. Prototyping…………………………………….86b. Rapid Application Development [RAD]……...87c. Joint Application Design [JAD]………….……87

4

Page 5: Hostel Report 1

PART I[C++ Project]

HOSTEL

Management

System

5

Page 6: Hostel Report 1

Introduction

6

Page 7: Hostel Report 1

Introduction

This project is basically for the user's who want to develop C++ menu driven

programs and building application through their real life. It contains an assumed example

of an organization (XYZ Hostel). The personnel information of the organization interacts

with regard to the student management, the various committees, and personal

information. Also they have number of terms and conditions given in the programs by

comment line either in // or /*. It comprises a menu driven program, and includes number

of options, procedures for each selective module with a complete class declaration of

OOPS concept. The complete project handles various different file handling techniques.

This project includes number of libraries including different header files and their

respective functions which are noted down after the source code of the project.

7

Page 8: Hostel Report 1

Description

8

Page 9: Hostel Report 1

Description of the Project

The project "THE HOSTEL MANAGMENT" contains the entire enquiry about

the entries made by students, bills to be paid, fines to be given, the work done by various

committees, the members belonging to the various committees and finally the various

rules of the committee. All committees included are MESS, DISCIPLINE, and

MAINTENANCE. Along with this a record of all the entries are also kept in the

ENTRIES CLASS. Data of each student is the main parts in this project which is kept

under the STUDENT CLASS.

The most secure feature of this project is the user cannot use the program without

any knowledge of the password. At first, the user is shown the screen with the three

options – user options, administrative menu and exit. After the user enters the desired

choice, the user is asked for the password. Only after entering the right password only,

the user can proceed ahead. Otherwise the user will be asked to re-enter the password or

return back to the main menu. Not only this, the user can enter the administrative menu

and change the password. This can help the user to maintain top level security as the user

has no limits and can change the password as many times as desired. This gives the

feature of user-friendliness to the program. So as a result, we can see that this password

feature gives this extra security to this program.

Let’s start of with the MESS committee class. Well this class includes the main

things. First is the basic rules that are to be followed by the members of the committee.

Not only the members but also other students have to follow these rules. Second thins is

that when the user inputs. The information that is asked is the name, roll number, current

semester, branch and finally the room number. Now this serves as tow purpose. The user

can either use to keep track of the members of the committee. On the other hand, the user

can also use to keep track of the people who will eat in the mess. But the first purpose is

served better since it is obvious that everyone who stays at the hostel will eat in the mess.

The next class is the MAINTENANCE committee class. This is the class in which

the basic information regarding any maintenance needed for the smooth running of the

hostel. In this class the user is required to enter the number of beds, chairs and tables

9

Page 10: Hostel Report 1

needed to be maintenance. Along with this, the user can also add other items that may

need any repairs.

Then we have the DISCIPLINE class. This class actually includes all the fines

that are made on the students throughout the year. In this, the user will enter the name,

branch, roll number, room number, imposed fine and the corresponding date. After

making the various entries, the user also has the option of inputting if the student has paid

the fine or not. For this, the user can select the modify menu and modify the

corresponding fine to zero. This is a very important feature as the record of all the fines

every made on the students will always stay there. Hence no one can delete the record.

Last but not least, we have another class known as the ENTRIES class. This is the

class in which the student will make any entries made by them through out the year.

When the user selects the entries menu from the student’s information choice, the user is

given several choices. Under the input menu the user will have to provide the name,

branch, room number, roll number, date out, date in and the place. This will help to keep

track of each and every student. This will ensure that the authorities can keep track on

each and every student’s activities, a very important aspect of this project.

Finally, there is the last class know as the STUDENT class. This is the class in

which all the basic information regarding the students is input here. All the students who

are living in the hostel currently are added her. Under this menu, the user is asked to

provide the student’s name, father’s name, phone number, room number, branch and

finally the address. This will help in giving all the information regarding the student to

the authorities.

To give all of this an extra touch, we also added graphics. From the beginning till

the end all the main menus included in the source code are made under the graphics

made. But all the various sub-menus have not been included in the graphics for the sake

of simplicity and time shortage. But overall, the user will be provided with a very up-to-

date interface with various different colors.

10

Page 11: Hostel Report 1

Objectives

11

Page 12: Hostel Report 1

Objectives of the Project

This project of Hostel Management System provides many different objectives.

Our first aim is provide a project that is as complete as we can do it. This means that we

have tried to include many different aspects of a hostel. We tried to stimulate the real-

world of a hostel into this computer generated world of C++. This in fact demonstrates

the concepts of OOPS, a feature of C++. Along with these objectives, we have also tried

to make the project as much simple and user-friendly. By using various different

graphics, the user is introduced to a welcoming screen. This will help to build confidence

in the user, especially the naive users who try to avoid using C++ at all. This can help

them and also provide a friendly environment for the expert-users also.

Another important objective of this management system about the hostel is the

various use of file handling. Through out the project, all the concepts of file handling are

used to the fullest. Various different commands of adding, modifying, displaying,

deleting and searching are used and all of this is made possible with the help of file

handling. So by the end of this project, the programmer is made to be an expert in this

field of file handling.

A very important feature of this program is to make the life of the authorities less

effort able. With just few entries in the program, the user can get any data regarding

anything they have entered in the project.

12

Page 13: Hostel Report 1

Modules

13

Page 14: Hostel Report 1

Modules of the Project

C++

Like c, c++ began its life at Bell Labs, where Bjarne Stroustrup developed the

language. Stroustrup added oops features to C without significantly changing the C

component. Thus C++ is a superset of C. OOPS here signifies the object oriented

programming. Its features are inheritance, classes, polymorphism, encapsulation.

CLASSES

The entity of C++ is called CLASS that too can hold data and functions. There

is almost no difference in the syntax of structure and a class. Structures are used to hold

data and classes are used to hold both data and functions. There can be classes within

the classes, more than one class in a program, multi-declaration of objects, use of array

within the class. We can set pointers to object. Classes are the main part that has been

included in this project. Many classes have been declared in this project that are

described below:

STUDENT:

This class includes the basic information about the student's name, roll no,

father's name and their addresses. This is all about the student’s information. Other part

includes the entries that have been made by students preferably called as IN/OUT

entries. Private data consist of private information likely their phone nos and addresses

MESS:

This is one of the committee of the hostel management system. Mess committee

has to take care of time to time entries and various bills, so required information has

been put in the same class.

DISCIPLINE:

Discipline committee here has to take care of all fines imposed on students. So

the data has to be kept is the total no. of fines imposed on students. The class involves

14

Page 15: Hostel Report 1

the name of the student and the fine imposed on that particular student.

MAINTENENCE:

Maintenance committees keep the records of no. of stocks, furniture required

and cleanliness. So this class has the information about no of stocks or the no. of chair

table required etc.

SWITCH STATEMENT

Switch statement

switch statement selects one from many alternatives.

FORMAT:

switch (expression)

{ case value 1:block-1

break;

case value 2:block-2

break;

:

:

default :default block

break;

}

statement-x

The expression is an integer or characters. if the expression contains characters,

the value will be integrated.

The expression will be evaluated. the integrated value will be compared with

case values. If a match occurs, the corresponding statement block will be executed.

If no match occurs, then the statement block against default will be executed.

In this project, switch statement is often used. Firstly to call MAIN MENU which has 3

cases- USER MENU, ADMINISTATOR MENU, EXIT.

15

Page 16: Hostel Report 1

Secondly it has been used in case of choices of students information and

Committees information. Then again switch statement is there for our choice for mess

or discipline or maintenance and similarly for fines imposed and personal information

of students.

So by the use of switch statement the success is achieved in logical as well as simpler

way.

GOTO

A goto statement transfers control of the program to the statement whose label is

specified after the goto keyword.

FORMAT:

goto label; label:

-------- statement;

-------- ----------

-------- ----------

label: ---------

statement; goto label;

IOSTREAM.H

Iostream.h file is called header file. The general syntax by using the #include

linker is: #include<iostream.h>

The iostream offer more or less the same set of possibilities as the standards

streams of C. Inputting is done using cin>> and outputing using cout<<. cin and cout

has already defined in this header file.

16

Page 17: Hostel Report 1

CONIO.H

Conio.h is the other header file. It has the functions- clrscr() and getch() defined

in it. clrscr() is used to clear the previous output. getch() is used to get character on the

screen during the execution and output of the program.

STRING.H

To handle or to operate strings, we use some string handling functions like

i) strcat()

ii) strcmp()

iii) strcpy()

iv) strlen()

if-else STATEMENT

This statement also has a single condition, but it has two blocks. One is true block and

other is false block.

The general syntax is:

if(condition)

{

True Statement Block;

}

else

{

False Statement Block;

}

statement-x;

17

Page 18: Hostel Report 1

While STATEMENT

While statement or while loop is an entry control loop. In this, first of all

condition is checked and if it is true then group of statements or body of loop will be

executed. it will execute again and again till condition becomes false.

The general syntax is:

while(test condition)

{

block of statements;

}

statement-x

C++ GRAPHICS

C++ includes an extensive collection of graphics-oriented library functions.

These functions open up an exciting new world. With them you can place almost any

son of image on the screen. Graphics and object-oriented programming work together

particularly well because specific images, such as balls, can be represented by objects.

Graphics provides a visual way to see objects in action.

C++ graphics functions fall into two categories: those that work in text mode

and those that work in graphics mode. Graphics- mode functions allow you to draw

dots, lines, and shapes, add color to lines and areas, and perform many other graphics-

related activities.

TEXT MODE GRAPHICS

C++ adds additional text-mode functions to facilitate writing text to windows. A

window in this context is a rectangular area on the screen that confines the text written

18

Page 19: Hostel Report 1

to it.

Windows are useful in programs that use a Graphical User Interface (GUI)

display in text mode. The Turbo C++ environment itself is an example of this kind of

display. It uses windows in character mode.

THE textcolor () FUNCTION

The fifth argument of the five-argument function constructor specifies the color

to be used for the box outline and for the text given in the box. This color value is

stored as a private-member of the box class. our member function draw() supplies this

values foe the argument to textcolor(), which it executes before displaying the

characters.

Other functions, which we don’t use in the program, can b used to change the

appearance of text written to the screen. For instance, you can set the background color

for each character with textbackground () library function.

The Graphics Driver

To specify the mode, you need to choose appropriate values for the parameters to

initgraph (). The first argument to intigraph () specifies the graphics driver to be used.

The Graphics Mode

The second parameter to intigraph () specifies the particular mode.

Here are the statements use to initialize EGAHI mode:

int driver=EGA; //EGA"driver

int mode= EGAHI; //EGA hires mode

Initgrah (&driver, &mode,"C:\\TC\\BGI");

19

Page 20: Hostel Report 1

BAR FUNCTION

Draws a bar

Declaration: void far bar (int left,int top, int right, int bottom);

Remarks:

Bar draws a filled-in, rectangular, two dimensional bar.

The bar is filled using the current fill pattern and fill color. bar does not outline the bar.

the coordinates are in pixels.

Return Value: NONE

SETTEXTSTYLE FUNCTION

Sets the current text characteristics

Declaration:

void far settextstyle(int font, int direction, int char size);

Remarks:

settexttyle sets the text font, the directions in which text is displayed, and the size of the

characters.

A call to settextstyle affects the all text putput by puttext and outtextxy.

OUTTEXT, OUTTEXTXY, FUNCTIONS

#outtext displays a string in the viewport

#outtextxy displays a string at the specified location

Declaration:

#void far outtext (char far*textstring);

#void far outtextxy (intx, inty, char far*textstring);

Remarks:

outtext and outtextxy display a text string, using the current justification settings and

the current font, direction, and size.

20

Page 21: Hostel Report 1

#outtext outputs textstring at the current position (CP)

#outtextxy displays textstring in the viewport at the position(x,y)

With outtext, if the horizontal text justification is LEFT_TEXT and the text direction is

HORIZ_TEXT, the CP's x-coordinate is advanced by textwidth (textstring)

Return Value: NONE

FILE HANDLING

CLASSES FOR FILE STREAM OPERATIONS

The I/O system of C++ contains a set of classes that define the file I/O handling

methods. These include ifstream, ofstream and fstream. These classes are declared in

fstream.h file.

ifstream -derived from istream used for input(reading)

ofstream -derived from ostream, used for file output(writing)

fstream -derived from iostream, used for both, file input & output

File Opening and Closing

The statement ofstream ofile ("temp.txt"); means that an object called ofile of the

stream class is create of and its constructor invoked with the value temp.txt.

There is another way to open and close a file.

i) Open () Function

Ifstream inf;

inf.open ("stock");

ii) Close () Function

21

Page 22: Hostel Report 1

Ofstream outf;

outf.open("stock");

Here the file stock is closed but the objectives still available in the program. It is

not associated with any particular data file. This technique of closing files is useful

when you want to use the same object to process many different files in a single

program.

Example using RANDOM ACCESS in FILE HANDLING:

#include<iostream.h>#include<conio.h>#include<fstream.h>#include<iomanip.h>class INVENTORY{

char name[10];int code;float cost;public:void getdata(void){cout<<"enter name:";cin>>name;cout<<"enter code:";cin>>code;cout<<"enter cost:";cin>>cost;}void putdata(void){

cout<<setw(10)<<name<<setw(10)<<code<<setprecision(2);cout<<setw(10)<<cost<<endl;

}};Void main(){

clrscr();INVENTORY item;int c=0;fstream inoutfile;inoutfile.open("STOCK2.DAT",ios::ate | ios::in |ios::out | ios::binary);

22

Page 23: Hostel Report 1

inoutfile.seekg(0,ios::beg);

while(c!=3){ clrscr();cout<<"1.Input"<<endl<<"2. Display"<<endl;cout<<”3. Modify”<<endl<<”4.Delete”<<endl;cout<<”5.Search”<<endl<<"6.Exit"<<endl<<"enter your choice ";cin>>c;

switch(c){

*********************************ADD*********************************case 1:cout<<"\n add an item\n";item.getdata();inoutfile.write((char*)&item,sizeof(item));inoutfile.seekg(0);getch();break;

*********************************DISPLAY*****************************

case 2:cout<<"curr. contents of stoock"<<"\n";while(inoutfile.read((char*)&item,sizeof(item))){item.putdata();}getch();inoutfile.clear();break;

*********************************MODIFY*****************************

case3:char ch;int last=inoutfile.tellg();int n=last/sizeof(item) ;cout<<"No. of objects= \t"<<n<<endl;cout<<"Total bytes in a file = \t"<<last<<endl;cout<<"Enter objects no. to be updated: \t"<<endl;int object;cin>>object;cin.get(ch);int location=(object-1)*sizeof(item);if(inoutfile.eof())

23

Page 24: Hostel Report 1

inoutfile.clear();inoutfile.seekp(location);cout<<"Enter new values of the object:"<<endl;obj2.getdata();cin.get(ch);inoutfile.write((char*)&obj2,sizeof(item))<<flush;inoutfile.seekg(0);cout<<"Contents of updated file"<<endl;while(inoutfile.read((char*)&obj2,sizeof(item)))

{obj2.putdata();}

getch();break;

*********************************DELETE*****************************

case 4:char name1[20];fstream file;file.open("STOCKS2.DAT", ios::in|ios::binary) ;fstream temp;temp.open("temp.txt", ios::out|ios::binary) ;file.seekg(0,ios::end);int endposition= file.tellg();int nr= endposition/sizeof(item);cout<<"\nThere are "<<nr<<" objects.";int c;cout<<"\nEnter the record no.";cin>>c;int position= (c-1)*sizeof(item);file.seekg(position);file.read((char *)&item, sizeof(item));item.putdata();cout<<"\nEnter name for confirmation: ";gets(name1);file.seekg(0, ios::beg);while ( !file.eof() )

{file.read((char *)&item, sizeof(item));if ( file.eof() )

{break;}

if (strcmp(name1,item.retname())!=0){

24

Page 25: Hostel Report 1

temp.write((char *)&item, sizeof(item));}

}file.close();temp.close();file.open("STOCKS2.DAT", ios::out|ios::binary);temp.open("temp.txt", ios::in|ios::binary);temp.seekg(0,ios::beg) ;while ( !temp.eof() )

{temp.read((char *) &item, sizeof(item));if ( temp.eof() )break;file.write((char *) &item, sizeof(item));}

file.close() ;temp.close();cout<<"\n RECORD DELETED.\n”;cout<<”PRESS ANY KEY TO CONTINUE......";getch();break;

*********************************SEARCH*****************************

case 5:fstream inoutfile;file.open("STOCKS2.DAT", ios::in|ios::binary) ;inoutfile.seekg(0, ios::beg);char name[10];cout<<"ENTER NAME TO BE SEARCHED: ";gets(name);inoutfile.read((char*)&item,sizeof(item));while(!inoutfile.eof())

{if(strcmp(name,item.retname())==0)

{cout<<"\nDETAILS FOUND:\n ";item.putdata();break;}

inoutfile.read((char*)&item,sizeof(item));}

if(inoutfile.eof())cout<<"RECORD NOT FOUND\n\n”;cout<<”Press any key to continue... ";inoutfile.close();

25

Page 26: Hostel Report 1

getch();break;

case 6: break;}}inoutfile.close();return 0;}

26

Page 27: Hostel Report 1

Working of the Project

[Flow Charts]

27

Page 28: Hostel Report 1

Working of the Project

A program is a sequence of instructions written in a programming language.

There are various programming languages, each having its own advantage for program

development. Generally every program takes an input, manipulates it and provides an

output as shown below:

A conceptual view of a program

For better designing of a program, a systematic planning must be done. Planning

makes a program more efficient and more effective. A programmer should use planning

tools before coding a program. By doing so all the instructions are properly interrelated in

the program code and the logical errors are minimized.

28

PROGRAM CODE

INPUT

OUTPUT

Page 29: Hostel Report 1

Flow Chart for Displaying

29

OPENING FILE IN INPUT MODE

TAKING POINTER TO

DESIRED POSITION

READING FILE AND COPYING TO OBJECT OF

CLASS

CALLING FUNCTION TO SHOW DATA

CLOSING OF FILE

Page 30: Hostel Report 1

FALSE

FALSE

Flow Chart for Deletion

30

READ FILE.DAT

OPENING & CREATING FILE.DAT IN INPUT MODE

ANDTEMP.DAT IN OUTPUT

MODE

TAKING POINTER TO BEGINNING

WHILE NOT END OF FILE

IF STRING IS NOT EQUAL TO THE

RECORD

COPY DATA FROM FILE.DAT TO TEMP.DAT

IF END OF FILE

EXIT

Page 31: Hostel Report 1

TRUE

FALSE

TRUE

FALSE

Flow Chart for Modification

31

OPENING & CREATING FILE.DAT IN INPUT MODE

ANDTEMP.DAT IN OUTPUT

MODE

TAKING POINTER TO BEGINNING

WHILE NOT END OF FILE

READ FILE.DAT

IF STRING IS NOT EQUAL TO THE

RECORD

COPY DATA FROM FILE.DAT TO TEMP.DAT

IF END OF FILE

CLOSE FILE & EXIT

CALL FUNCTION TO GET DATA &

WRITE TO TEMP.DAT

Page 32: Hostel Report 1

Flow Chart for Addition

32

ADD RECORD

CALLING FUNCTION TO GET DATA

OPENING & WRITING

RECORD ON FILE

CLOSING AND SAVING

Page 33: Hostel Report 1

FALSE

TRUE

Flow Chart for Searching

33

OPENING FILE IN READ MODE

TAKING POINTER TO BEGNING OF FILE

USING STRING COMPARING:

COMPARE NAMES

IF

NAME IS COMPARED

CALLING FUNCTION TO

SHOW DATA

EXIT

Page 34: Hostel Report 1

Snapshots/Result

34

Page 35: Hostel Report 1

Snapshots/Result of the Project

The first screen that the user will be displayed within the basic student information section

Various things that the user can do with the student information

35

CHOOSE ONE OF THE FOLLOWING:StudentEXIT

InputDisplayModifyDeleteSearchReturn Enter Your Choice:

Page 36: Hostel Report 1

The input screen in which the user will have to feed in some data

The display screen in which the user will be shown all the data entered

36

1. Input2. Display3. Modify4. Delete5. Search6. Return

Enter Your Choice: 2 Current content of stock:

Name Father’s Name Address Phone Number Branch

Rohit Mr.Bahadhur C-Block, Batala 9876453627 CSE

1. Input2. Display3. Modify4. Delete5. Search6. Return

Enter Your Choice: 1 Add an item:

Name: NavdeepFather’s Name: Mr.GuptaAddress: F-Block, DelhiPhone Number: 9988776655Branch: IT

Contents of appended file:Name Father’s Name Address Phone Number Branch

Navdeep Mr.Gupta F-Block, Delhi 9988776655 IT

Page 37: Hostel Report 1

The modify screen in which the user can modify any data they have already entered

The delete screen in which the user can delete any data they have already entered

37

1. Input2. Display3. Modify4. Delete5. Search6. Return

Enter Your Choice: 4 There is 1 object. Enter the record no. 1

Name Father’s Name Address Phone Number Branch

Rohit Mr.Bahadhur C-Block, Batala 9876453627 CSE

Enter name for confirmation: Rohit

RECORD DELETED PRESS ANY KEY TO CONTINUE……………

1. Input2. Display3. Modify4. Delete5. Search6. Return

Enter Your Choice: 3 No. of objects= 1 Total bytes in a file= 104 Enter object no. to be update: 1

Enter new value of the objects:Name: MohitFather’s Name: Mr.pankajAddress: B-Block, AmritsarPhone Number: 9847654321Branch: ECE

Contents of updated file:Name Father’s Name Address Phone Number Branch

Mohit Mr.Sharma B-Block, Amritsar 9847654321 ECE

Page 38: Hostel Report 1

The search screen in which the user can search any data they have entered

38

1. Input2. Display3. Modify4. Delete5. Search6. Return

Enter Your Choice: 5

ENTER NAME TO BE SEARCHED: Rohit

DETAIL FOUND:

Name Father’s Name Address Phone Number Branch

Rohit Mr.Bahadhur C-Block, Batala 9876453627 CSE

Page 39: Hostel Report 1

Conclusion

39

Page 40: Hostel Report 1

Conclusion

In conclusion, we would like to suggest that this project as a whole tries to

demonstrate and follow the real-life stimulation of the management in a hostel. We have

tried to include various aspects of the hostel. For instance along with the basic student

information and the various committees are also dealt in the project. The rules and the

various members of the committees are part of this committee class, which has been

discussed in the source code of the program. Overall this project provides a complete

inside into the Hostel Management System.

Apart from all our efforts in making this project as complete as possible, there are

still some loop holes through which various improvements can be made on the project.

We should have not use the goto and the if-while statement as much as we did in our

project. In future, the coder should keep in mind that the use of goto statement with the

use of if-while statement makes the project very complicated. The coders can, for

instance can define various functions at the beginning of the program for the sake of

simplicity. This will ensure that the use of curly braces ( {} ) will be used less and the

number of error will be decreased by a far lot. Not only this, but the user will not a

humongous program like we have it. The number of lines and the simplicity will ensure

that the program will run with complete smoothness without any difficulty.

Another improvement we would like to suggest is that the use of graphics. Since

we ran out of time and knowledge, we didn’t really have the time to make whole of this

project under the graphics mode. We did our best in including the maximum number of

graphics as possible. But still not the whole program as a whole is under graphics mode.

The use of graphics, in fact helps the user to interact with the program with a more

different approach. The user will be quiet more comfortable with this.

40

Page 41: Hostel Report 1

Appendix[Source Code of the program]

41

Page 42: Hostel Report 1

Appendix

#include <graphics.h>#include <dos.h>#include <iomanip.h>#include <iostream.h>#include <fstream.h>#include <stdlib.h>#include <string.h>#include <stdio.h>#include <conio.h>

//********************* STUDENT CLASS DEFINED *********************//

class student{protected:long int phno;char name[20];char fname[20];char address[50];char branch[10];

public:void getdata();void showdata();char * retname()

{return name;

}};void student::getdata(){cout<<"NAME: \t";cin>>name;cout<<"FATHER's NAME: \t";cin>>fname;cout<<"ADDRESS: \t";cin>>address;cout<<"PHONE NUMBER: \t";cin>>phno;cout<<"BRANCH: \t";cin>>branch;}

42

Page 43: Hostel Report 1

void student::showdata(){cout<<"\n NAME \t FATHER's NAME \t\t ADDRESS \t\t PHONE NUMBER \t BRANCH \n";cout<<" "<<name<<"\t "<<fname<<"\t\t\t "<<address<<"\t\t\t ";cout<<phno<<"\t "<<branch;}

//******************** ENTERIES CLASS DEFINED **********************//

class enteries{char name[20];int rollnumber;char branch[10];int roomnum;int dateout;int datein;char place[20];public:void getdata(){cout<<"NAME: \t";cin>>name;cout<<"ROLL NO: \t";cin>>rollnumber;cout<<"BRANCH: \t";cin>>branch;cout<<"ROOM NUMBER: \t";cin>>roomnum;cout<<"Date OUT: \t";cin>>dateout;cout<<"Date IN: \t";cin>>datein;cout<<"PLACE: \t";cin>>place;}void showdata(){cout<<"\n NAME \t ROLL NO. \t BRANCH \t ROOM NO. \t OUT \t IN \t PLACE \n";cout<<setw(4)<<name<<"\t"<<setw(6)<<rollnumber<<"\t";cout<<setw(13)<<branch<<setw(16)<<roomnum;cout<<setw(14)<<dateout<<setw(8)<<datein<<setw(11)<<place;}char * retname()

43

Page 44: Hostel Report 1

{return name;

}};

//************************** MESS CLASS DEFINED ********************//

class mess{protected:char name[20];char bh[10];int rollnum;int rnum;int sem;public:void getdata(){cout<<"NAME: \t";cin>>name;cout<<"ROLL Number: \t";cin>>rollnum;cout<<"BRANCH: \t";cin>>bh;cout<<"ROOM Number: \t";cin>>rnum;cout<<"Current SEMESTER: \t";cin>>sem;}void showdata(){cout<<"\n NAME"<<setw(8)<<"\t"<<"ROLL NO."<<setw(5)<<"\t"<<"BRANCH";cout<<setw(8)<<"\t"<<"ROOM NO."<<setw(8)<<"\t"<<"SEMESTER \n";cout<<name<<"\t\t"<<rollnum<<"\t\t"<<bh<<"\t\t"<<rnum<<"\t\t"<<sem;}char * retname()

{return name;

}};

//********************* DISCIPLINE CLASS DEFINED ********************//

class discipline {

44

Page 45: Hostel Report 1

char name[20]; int rollno; int fine; int date; int month; int year; char bran[10]; public: void getdata() { cout<<"NAME: \t"; cin>>name; cout<<"ROLL NUMBER: \t"; cin>>rollno; cout<<"BRANCH: \t"; cin>>bran; cout<<"IMPOSED FINE: \t"; cin>>fine; cout<<"DATE of FINE: \t"; cin>>date; cout<<"MONTH of FINE: \t"; cin>>month; cout<<"YEAR of FINE: \t"; cin>>year; } void showdata() { cout<<"\n NAME"<<"\t"<<"ROLL NO."<<setw(6)<<"\t"<<"BRANCH"; cout<<setw(19)<<"IMPOSED FINE"<<setw(9)<<"DATE"<<setw(9)<<"MONTH"; cout<<setw(9)<<"YEAR \n"; cout<<name<<"\t"<<rollno<<"\t\t"<<bran<<"\t\t"<<fine<<"\t\t"<<date; cout<<"\t"<<month<<setw(9)<<year<<"\n"; } char * retname()

{return name;

} };

//******************* MAINTENANCE CLASS DEFINED ******************//

class maintenance{int c;int t;

45

Page 46: Hostel Report 1

int b;int o;public:void getdata(){cout<<"No. of CHAIRS: \t";cin>>c;cout<<"No. of TABLES: \t";cin>>t;cout<<"No. of BEDS: \t";cin>>b;cout<<"OTHER items needed for Maintenance: \t";cin>>o;}void showdata(){cout<<"\n CHAIRS \t TABLES \t BEDS \t OTHER Items \n";cout<<setw(3)<<c<<"\t\t"<<setw(5)<<t<<"\t\t"<<setw(3)<<b<<"\t\t"<<o<<"\n";}};

//*********************************************************************////**************************** MAIN PROGRAM ************************////*********************************************************************//

void main(){ int gdriver = DETECT, gmode, errorcode; int style, midx, midy; int left,right,top,bottom; initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); midx = getmaxx() / 2; midy = getmaxy() / 2; setbkcolor(8); for(int n=1;n<4;n++) { setcolor(n); settextjustify(CENTER_TEXT, CENTER_TEXT); cleardevice(); settextstyle(10, HORIZ_DIR, n); outtextxy(midx, midy, "HOSTEL MANAGEMENT SYSTEM");

46

Page 47: Hostel Report 1

delay(290); } delay(300);

int ptr; int i,mchoice,ch,schoice; char word[30],ans[100]; char *buf1= "hostel", *buf2, *buf3; midx=getmaxx()/2; midy=getmaxy()/2; fstream file; file.open("HOSTEL.txt",ios::ate | ios::in | ios::out | ios::binary); a: clrscr(); setbkcolor(3); cleardevice(); left=getmaxx()/2-250; top=getmaxy()/2-220; right=getmaxx()/2+250; bottom=getmaxy()/2+220; bar(left,top,right,bottom); settextstyle(6,HORIZ_DIR,8); setcolor(5); outtextxy(320,40,"MAIN MENU"); settextstyle(3,HORIZ_DIR,4); setcolor(12); outtextxy(300,150,"\n 1. User Option \n"); outtextxy(300,185,"\n 2. Administrator Option \n"); outtextxy(300,220,"\n 3. Exit \n"); settextstyle(5,HORIZ_DIR,4); outtextxy(330,350," Enter Your Choice "); moveto(350,370); cin>>mchoice;

//************** CHOICE 1. ******************//

switch(mchoice) {

case 1:

x: clrscr(); setbkcolor(3); cleardevice(); bar(left,top,right,bottom); setcolor(4);

47

Page 48: Hostel Report 1

settextstyle(5,HORIZ_DIR,6); outtextxy(midx,midy," Enter Password "); gets(buf2); ptr=strcmpi(buf2,buf1); if(ptr==0)

{ y: clrscr(); setbkcolor(3); cleardevice(); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(330,40," User Menu "); setcolor(1); settextstyle(3,HORIZ_DIR,4); outtextxy(320,150,"1. Student's Information"); outtextxy(320,225,"OR"); outtextxy(320,290,"2. Committee Information"); settextstyle(5,HORIZ_DIR,4); outtextxy(330,380,"Enter your choice"); cin>>ch; if(ch==1)

{ usm: clrscr(); setbkcolor(3); cleardevice(); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(330,40," User Menu "); setcolor(1); settextstyle(3,HORIZ_DIR,4); outtextxy(300,100,"\n 1. Find The Fines \n"); outtextxy(300,145,"\n 2. Find The Various Enteries \n"); outtextxy(300,190,"\n made by the Student \n"); outtextxy(300,235,"\n 3. Basic Student Information \n"); outtextxy(300,315,"\n 4. Back To Main Menu \n"); settextstyle(5,HORIZ_DIR,4); outtextxy(330,380," Enter Your Choice "); cin>>schoice; switch(schoice)

{case 1:

48

Page 49: Hostel Report 1

int k;p:clrscr();cout<<"Choose one of the following \n ";cout<<"\n 1. Discipline";cout<<"\n 2. Exit";cin>>k;

if(k==1){clrscr();int c=0;fstream inoutfile;discipline obj2;inoutfile.open("Disci.txt",ios::ate | ios::in |ios::out | ios::binary);inoutfile.seekg(0,ios::beg);while(c!=4)

{hul:clrscr();cout<<"1.Input"<<endl;cout<<"2.Display"<<endl;cout<<"3.Modify"<<endl;cout<<"4.Delete"<<endl;cout<<"5.Search"<<endl<<"6.Return";cout<<endl<<"Enter your choice ";cin>>c;switch(c)

{case 1:cout<<"\n Add an item\n";obj2.getdata();inoutfile.write((char*)&obj2,sizeof(obj2));inoutfile.seekg(0);cout<<"CONTENTS OF APPEND FILE";while(inoutfile.read((char*)&obj2,sizeof(obj2))){obj2.showdata();}getch();break;

case 2:

49

Page 50: Hostel Report 1

cout<<"Current contents of stock";cout<<"\n";inoutfile.seekg(0,ios::beg);while(inoutfile.read((char*)&obj2, sizeof(obj2))){obj2.showdata();}getch();inoutfile.clear();break;

case 3:char ch;int last=inoutfile.tellg();int n=last/sizeof(obj2) ;cout<<"No. of objects= \t";cout<<n<<endl;cout<<"Total bytes in a file = \t";cout<<last<<endl;cout<<"Enter objects no. to be updated: \t";cout<<endl;int object;cin>>object;cin.get(ch);int location=(object-1)*sizeof(obj2);if(inoutfile.eof())inoutfile.clear();inoutfile.seekp(location);cout<<"Enter new values of the object:";cout<<endl;obj2.getdata();cin.get(ch);inoutfile.write((char*)&obj2,sizeof(obj2))<<flush;inoutfile.seekg(0);cout<<"Contents of updated file";cout<<endl;while(inoutfile.read((char*)&obj2,sizeof(obj2))){obj2.showdata();}getch();

50

Page 51: Hostel Report 1

break;

case 4:char name1[20];fstream file;file.open("disci.txt", ios::in|ios::binary) ;fstream temp;temp.open("temp.txt", ios::out|ios::binary) ;file.seekg(0,ios::end);int endposition= file.tellg();int nr= endposition/sizeof(obj2);cout<<"\n There are "<<nr;cout<<" objects.";int c;cout<<"\n Enter the record no.";cin>>c;int position= (c-1)*sizeof(obj2);file.seekg(position);file.read((char *)&obj2, sizeof(obj2));obj2.showdata();cout<<"\nEnter name for confirmation: ";gets(name1);file.seekg(0, ios::beg);while ( !file.eof() )

{file.read((char *)&obj2, sizeof(obj2));if ( file.eof() )

{break;

}if (strcmp(name1,obj2.retname())!=0)

{temp.write((char *)&obj2, sizeof(obj2));}

}file.close();temp.close();file.open("disci.txt", ios::out|ios::binary);

51

Page 52: Hostel Report 1

temp.open("temp.txt", ios::in|ios::binary);temp.seekg(0,ios::beg) ;while ( !temp.eof() )

{

temp.read((char *) &obj2,

sizeof(obj2)); if ( temp.eof() )

break;

file.write((char *) &obj2,

sizeof(obj2));}

file.close() ;temp.close();cout<<"\n RECORD DELETED.\n; cout<<PRESS ANY KEY TO cout<<CONTINUE......";getch();goto hul;break;

case 5:fstream inoutfile;file.open("disci.txt", ios::in|ios::binary);inoutfile.seekg(0, ios::beg);char name[10];cout<<"ENTER NAME TO BE SEARCHED: ";gets(name);inoutfile.read((char*)&obj2,sizeof(obj2));while(!inoutfile.eof()){

if(strcmp(name,obj2.retname())==0){cout<<"\nDETAILS FOUND:\n ";obj2.showdata();break;

52

Page 53: Hostel Report 1

}

inoutfile.read((char*)&obj2,sizeof(obj2));}if(inoutfile.eof())cout<<"RECORD NOT FOUND.”;cout<<”\n Press any key to continue... ";inoutfile.close();getch();break;

case 6:goto p;break;

} //end of switch(c)} //end of while(c)

} //end of if(k==1)

if(k==2){ clrscr(); cout<<"THANK YOU"; getch(); exit (0);}

break;

case 2: const int size=2; run: int abcd; clrscr(); cout<<"Choose one of the following \n "; cout<<"\n 1. Entries"; cout<<"\n 2. Exit"; cin>>abcd;

if(abcd==1){clrscr();enteries e[size];int c=0;fstream inoutfile;

53

Page 54: Hostel Report 1

inoutfile.open("Entries.txt",ios::ate | ios::in |ios::out | ios::binary);inoutfile.seekg(0,ios::beg);while( c!=4)

{clrscr();cout<<"1.Input"<<endl;cout<<"2.Display"<<endl;cout<<"3.Modify"<<endl;cout<<"4.Delete"<<endl;cout<<"5.Search"<<endl<<"6.Return";cout<<endl<<"Enter your choice ";cin>>c;switch(c)

{case 1:cout<<"\n Add an item\n";e[size].getdata();inoutfile.write((char*)&e[size],sizeof(e[size]));inoutfile.seekg(0);cout<<"CONTENTS OF APPEND FILE";

while(inoutfile.read((char*)&e[size],sizeof(e[size])))

{e[size].showdata();}getch();break;

case 2:cout<<"Current contents of stock";cout<<"\n";inoutfile.seekg(0,ios::beg);while(inoutfile.read((char*)&e[size], sizeof(e[size]))){e[size].showdata();}getch();inoutfile.clear();break;

case 3:char ch;

54

Page 55: Hostel Report 1

int last=inoutfile.tellg();int n=last/sizeof(e[size]) ;cout<<"No of objects= \t";cout<<n<<endl;cout<<"Total bytes in a file = \t";cout<<last<<endl;cout<<"Enter objects no. to be updated: \t";cout<<endl;int object;cin>>object;cin.get(ch);int location=(object-1)*sizeof(e[size]);if(inoutfile.eof())inoutfile.clear();inoutfile.seekp(location);cout<<"Enter new values of the object";cout<<endl;e[size].getdata();cin.get(ch);inoutfile.write((char*)&e[size],sizeof(e[size]))<<flush;inoutfile.seekg(0);cout<<"Contents of updated file";cout<<endl;while(inoutfile.read((char*)&e[size],sizeof(e[size]))){e[size].showdata();}getch();inoutfile.clear();break;

case 4:char name1[20];fstream file;file.open("entries.txt", ios::in|ios::binary) ;fstream temp;temp.open("temp.txt", ios::out|ios::binary) ;file.seekg(0,ios::end);int endposition= file.tellg();

55

Page 56: Hostel Report 1

int nr= endposition/sizeof(e[size]);cout<<"\nThere are "<<nr;cout<<" objects.";int c;cout<<"\nEnter the record no.";cin>>c;int position= (c-1)*sizeof(e[size]);file.seekg(position);file.read((char *)&e[size], sizeof(e[size]));e[size].showdata();cout<<"\nEnter name for confirmation: ";gets(name1);file.seekg(0, ios::beg);while ( !file.eof() )

{file.read((char *)&e[size], sizeof(e[size]));if ( file.eof() )

{break;

}if (strcmp(name1,e[size].retname())!=0)

{temp.write((char *)&e[size],sizeof(e[size]));}

}file.close();temp.close();file.open("disci.txt", ios::out|ios::binary);temp.open("temp.txt", ios::in|ios::binary);temp.seekg(0,ios::beg) ;while ( !temp.eof() )

{

temp.read((char *) &e[size], sizeof(e[size]));

if ( temp.eof() ) break;

file.write((char *) &e[size],

56

Page 57: Hostel Report 1

sizeof(e[size]));}

file.close() ;temp.close();cout<<"\n RECORD DELETED.\n”;cout<<”PRESS ANY KEY TO”; cout<<”CONTINUE......";getch();break;

case 5:fstream inoutfile;inoutfile.seekg(0, ios::beg);char name[10];cout<<"ENTER NAME TO BE SEARCHED: ";gets(name);inoutfile.read((char*)&e[size],sizeof(e[size]));while(!inoutfile.eof()){if(strcmp(name,e[size].retname())==0)

{cout<<"\nDETAILS FOUND:\n ";e[size].showdata();break;}

inoutfile.read((char*)&e[size],sizeof(e[size]));}if(inoutfile.eof())cout<<"RECORD NOT FOUND\n”;cout<<”Press any key to continue...";inoutfile.close();getch();break;

case 6:goto run;break;} // end of switch(c)

} // end of while(c!=3)} // end of if(abcd==1)

57

Page 58: Hostel Report 1

if(abcd==2){clrscr();cout<<"THANK YOU";getch();}

break;

case 3: clrscr(); int stud; cout<<"Choose one of the following \n "; cout<<"\n 1. Student"; cout<<"\n 2. Exit"; cin>>stud;

if(stud==1){clrscr();student st1;int c=0;fstream inoutfile;inoutfile.open("Student.txt",ios::ate | ios::in |ios::out | ios::binary);inoutfile.seekg(0,ios::beg);while( c!=4)

{clrscr();int s;cout<<"1.Input"<<endl<<"2.Display";cout<<endl<<"3.Modify"<<endl;cout<<"4.Delete"<<endl;cout<<"5.Search"<<endl<<"6.Return";cout<<endl<<"Enter your choice ";cin>>s;switch(s)

{case 1:cout<<"\n Add an item\n";st1.getdata();inoutfile.write((char*)&st1,sizeof(st1));inoutfile.seekg(0);cout<<"CONTENTS OF APPEND FILE";

58

Page 59: Hostel Report 1

while(inoutfile.read((char*)&st1,sizeof(st1))){st1.showdata();}getch();break;

case 2:cout<<"Current contents of stock";cout<<"\n";inoutfile.seekg(0,ios::beg);while(inoutfile.read((char*)&st1, sizeof(st1))){st1.showdata();}getch();inoutfile.clear();break;

case 3:char che;int last=inoutfile.tellg();int n=last/sizeof(st1) ;cout<<"No of objects= \t";cout<<n<<endl;cout<<"Total bytes in a file = \t";cout<<last<<endl;cout<<"Enter objects no. to be updated: \t";cout<<endl;int object;cin>>object;cin.get(che);int location=(object-1)*sizeof(st1);if(inoutfile.eof())inoutfile.clear();inoutfile.seekp(location);cout<<"Enter new values of the object";cout<<endl;st1.getdata();cin.get(che);inoutfile.write((char*)&st1,sizeof(st1))<<flush;

59

Page 60: Hostel Report 1

inoutfile.seekg(0);cout<<"Contents of updated file";cout<<endl;while(inoutfile.read((char*)&st1,sizeof(st1))){st1.showdata();}getch();inoutfile.clear();break;

case 4:char name1[20];fstream file;file.open("student.txt", ios::in|ios::binary) ;fstream temp;temp.open("temp.txt", ios::out|ios::binary) ;file.seekg(0,ios::end);int endposition= file.tellg();int nr= endposition/sizeof(st1);cout<<"\nThere are "<<nr;cout<<" objects.";int c;cout<<"\nEnter the record no.";cin>>c;int position= (c-1)*sizeof(st1);file.seekg(position);file.read((char *)&st1, sizeof(st1));st1.showdata();cout<<"\nEnter name for confirmation:";gets(name1);file.seekg(0, ios::beg);while ( !file.eof() )

{file.read((char *)&st1, sizeof(st1));if ( file.eof() )

{break;

}if (strcmp(name1,st1.retname())!=0)

60

Page 61: Hostel Report 1

{temp.write((char *)&st1, sizeof(st1));}

}file.close();temp.close();file.open("student.txt", ios::out| ios::binary);temp.open("temp.txt", ios::in| ios::binary);temp.seekg(0,ios::beg) ;while ( !temp.eof() )

{temp.read((char *) &st1, sizeof(st1)); if ( temp.eof() ) break;file.write((char *) &st1, sizeof(st1));}

file.close() ;temp.close();cout<<"\nRECORD DELETED.\n”;cout<<”PRESS ANY KEY TO”; cout<<”CONTINUE......";getch();break;

case 5:fstream inoutfile;

inoutfile.seekg(0, ios::beg);char name[10];cout<<"ENTER NAME TO BE SEARCHED: ";gets(name);

inoutfile.read((char*)&st1,sizeof(st1));while(!inoutfile.eof()){if(strcmp(name,st1.retname())==0)

{cout<<"\nDETAILS FOUND:\n ";st1.showdata();

61

Page 62: Hostel Report 1

break;}

inoutfile.read((char*)&st1,sizeof(st1));}if(inoutfile.eof())cout<<"RECORD NOT FOUND\n”;cout<<”Press any key to continue...";inoutfile.close();getch();break;

case 6:goto run;break;} // end of switch(s)

} // end of while(c!=3)} // end of if(stud==1)

if(stud==2){clrscr();cout<<"THANK YOU";getch();}

break;

case 4: goto a; break;

default: clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(5,HORIZ_DIR,6); outtextxy(midx,midy," Invalid Choice "); delay(2000); goto usm; break;} // end of switch(schoice)

} // end of if(ch==1)

if(ch==2)

62

Page 63: Hostel Report 1

{mmb:clrscr();setbkcolor(3);cleardevice();bar(left,top,right,bottom);setcolor(4);settextstyle(6,HORIZ_DIR,6);outtextxy(330,40," User Menu ");setcolor(1);settextstyle(3,HORIZ_DIR,4);outtextxy(300,150,"\n 1. Mess Committee \n");settextstyle(3,HORIZ_DIR,4);outtextxy(300,200,"\n 2. Maintenance Committee \n");settextstyle(3,HORIZ_DIR,4);outtextxy(300,315,"\n 3. Back To Main Menu \n");settextstyle(5,HORIZ_DIR,4);outtextxy(330,380," Enter Your Choice ");int committ;cin>>committ;switch(committ)

{case 1:int me;px:clrscr();cout<<"Choose one of the following \n ";cout<<"\n 1. Mess";cout<<"\n 2. Rules";cout<<"\n 3. Exit";cin>>me;if(me==1)

{clrscr();mess obj1;int c=0;fstream inoutfile;inoutfile.open("Mess.txt",ios::ate | ios::in |ios::out | ios::binary);inoutfile.seekg(0,ios::beg);while(c!=4)

{ff:clrscr();cout<<"1.Input"<<endl<<"2.Display";cout<<endl<<"3.Modify"<<endl;

63

Page 64: Hostel Report 1

cout<<"4.Delete"<<endl;cout<<"5.Search"<<endl<<"6.Return";cout<<endl<<"Enter your choice ";cin>>c;switch(c)

{case 1:cout<<"\n Add an item\n";obj1.getdata();inoutfile.write((char*)&obj1,sizeof(obj1));inoutfile.seekg(0);cout<<"CONTENTS OF APPEND FILE";while(inoutfile.read((char*)&obj1,sizeof(obj1))){obj1.showdata();}getch();break;

case 2:cout<<"Current contents of stock";cout<<"\n";inoutfile.seekg(0,ios::beg);while(inoutfile.read((char*)&obj1, sizeof(obj1)))

{obj1.showdata();}

getch();inoutfile.clear();break;

case 3:char ch;int last=inoutfile.tellg();int n=last/sizeof(obj1);cout<<"No. of objects= \t";cout<<n<<endl;cout<<"Total bytes in a file = \t";cout<<last<<endl;cout<<"Enter objects no. to be updated: \t";cout<<endl;

64

Page 65: Hostel Report 1

int object;cin>>object;cin.get(ch);int location=(object-1)*sizeof(obj1);if(inoutfile.eof())inoutfile.clear();inoutfile.seekp(location);cout<<"Enter new values of the object";cout<<endl;obj1.getdata();cin.get(ch);inoutfile.write((char*)&obj1,sizeof(obj1))<<flush;inoutfile.seekg(0);cout<<"Contents of updated file";cout<<endl;while(inoutfile.read((char*)&obj1,sizeof(obj1)))

{obj1.showdata();}

getch();goto ff;inoutfile.clear();break;

case 4:char name1[20];fstream file;file.open("mess.txt", ios::in| ios::binary) ;fstream temp;temp.open("temp.txt", ios::out| ios::binary) ;file.seekg(0,ios::end);int endposition= file.tellg();int nr= endposition/sizeof(obj1);cout<<"\nThere are "<<nr;cout<<" objects.";int c;cout<<"\nEnter the record no.";cin>>c;int position= (c-1)*sizeof(obj1);file.seekg(position);file.read((char *)&obj1,

65

Page 66: Hostel Report 1

sizeof(obj1));obj1.showdata();cout<<"\nEnter name for confirmation: ";gets(name1);file.seekg(0, ios::beg);while ( !file.eof() )

{file.read((char *)&obj1, sizeof(obj1));if ( file.eof() )

{break;

}if (strcmp(name1,obj1.retname())!=0)

{temp.write((char *)&obj1, sizeof(obj1));}

}file.close();temp.close();file.open("mess.txt", ios::out| ios::binary);temp.open("temp.txt", ios::in| ios::binary);temp.seekg(0,ios::beg) ;while ( !temp.eof() )

{

temp.read((char *) &obj1, sizeof(obj1));

if ( temp.eof() ) break;

file.write((char *) &obj1, sizeof(obj1));

}file.close() ;temp.close();cout<<"\nRECORD DELETED.\n”;cout<<”PRESS ANY KEY TO”; cout<<”CONTINUE......";getch();break;

66

Page 67: Hostel Report 1

case 5:fstream inoutfile;inoutfile.seekg(0, ios::beg);char name[10];cout<<"ENTER NAME TO BE SEARCHED: ";gets(name);inoutfile.read((char*)&obj1,sizeof(obj1));while(!inoutfile.eof()){

if(strcmp(name,obj1.retname())==0)

{cout<<"\nDETAILS FOUND:\n ";obj1.showdata();break;}

inoutfile.read((char*)&obj1,sizeof(obj1));

}if(inoutfile.eof())cout<<"RECORD NOT FOUND\n”;cout<<”Press any key to continue...";inoutfile.close();getch();break;

case 6:goto px;break;} // end of switch(c)

} // end of while(c!=3)} // end of if(me==1)

if(me==2) { clrscr(); cout<<"RULES"<<endl; cout<<"1.Students should be properly dressed."; cout<<endl; cout<<"2.The food will be served between the timings mentioned."<<endl; cout<<"3.For any complaints please mention them to the members of the committee."<<endl; getch();

67

Page 68: Hostel Report 1

} if(me==3) { clrscr(); cout<<"THANK YOU"; getch(); exit(0); }

break;

case 2:int punk;pxx:clrscr();maintenance obj1;cout<<"Choose one of the following: \n ";cout<<"\n 1. Maintenance";cout<<"\n 2. Rules";cout<<"\n 3. Exit";cin>>punk;if(punk==1)

{int c=0;clrscr();fstream inoutfile;inoutfile.open("Maint.txt",ios::ate | ios::in |ios::out | ios::binary);inoutfile.seekg(0,ios::beg);while(c!=4)

{maint:clrscr();cout<<"1.Input"<<endl<<"2.Display"<<endl;cout<<"3.Modify"<<endl<<"4.Return";cout<<endl<<"Enter your choice ";cin>>c;

switch(c){case 1:cout<<"\n Add an item\n";obj1.getdata();inoutfile.write((char*)&obj1,sizeof(obj1));inoutfile.seekg(0);

68

Page 69: Hostel Report 1

cout<<"CONTENTS OF APPEND FILE";while(inoutfile.read((char*)&obj1,sizeof(obj1))){obj1.showdata();}getch();break;

case 2:cout<<"Current contents of stock"<<"\n";inoutfile.seekg(0,ios::beg);while(inoutfile.read((char*)&obj1, sizeof(obj1))){obj1.showdata();}getch();inoutfile.clear();break;

case 3:char mu;int last=inoutfile.tellg();int n=last/sizeof(obj1) ;cout<<"No. of objects= \t"<<n<<endl;cout<<"Total bytes in a file = \t";cout<<last<<endl;cout<<"Enter objects no. to be updated: \t";cout<<endl;int object;cin>>object;cin.get(mu);int location=(object-1)*sizeof(obj1);if(inoutfile.eof())inoutfile.clear();inoutfile.seekp(location);cout<<"Enter new values of the object";cout<<endl;obj1.getdata();cin.get(mu);inoutfile.write((char*)&obj1,sizeof(obj1))<<flush;inoutfile.seekg(0);cout<<"Contents of updated file"<<endl;

69

Page 70: Hostel Report 1

while(inoutfile.read((char*)&obj1,sizeof(obj1))){obj1.showdata();}getch();goto maint;break;

case 4:goto pxx;break;} // end of switch(c)

} //end of while(c!=3)} // end of if(punk==1)

if(punk==2) { clrscr(); cout<<"RULES"<<endl; cout<<"1.Regular check of the supplies should be made properly."; cout<<endl; cout<<"2.Try to keep the environment arounf clean and tidy."<<endl; cout<<"3.Any brokage should be reported to the committee members.";

cout<<endl; getch(); } //end of if(punk==2) if(punk==3) { clrscr(); cout<<"THANK YOU"; getch(); exit(0); } //end of if(punk==3) break;

case 3: goto a; break;

default: clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(5,HORIZ_DIR,6); outtextxy(midx,midy," Invalid Choice ");

70

Page 71: Hostel Report 1

delay(2000); goto mmb; } // end of switch(committ)

} // end of if(ch==2)else{ clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(5,HORIZ_DIR,6); outtextxy(midx,midy," Invalid Choice "); delay(2000); goto y;} // end of else for if(ch==)

} //end of if(ptr==0) else {

clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(midx,40," Administrator Menu"); settextstyle(3,HORIZ_DIR,4); setcolor(1); outtextxy(midx,150," 1.Re-enter Password "); outtextxy(midx,185," 2.Back To Main Menu "); settextstyle(5,HORIZ_DIR,4); outtextxy(midx,390," Enter Your Choice"); int choice; cin>>choice; if(choice==1)

goto x;

else

goto a; }

break;

71

Page 72: Hostel Report 1

//************** CHOICE 2. ******************//

case 2:

h: clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(midx,midy," Enter Password "); gets(buf2); ptr=strcmpi(buf2,buf1); if(ptr==0) {

d: clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(330,40,"Administrator Menu"); settextstyle(3,HORIZ_DIR,4); setcolor(1); outtextxy(340,180,"1.Change Password "); outtextxy(340,290,"2.Back To Main Menu "); settextstyle(5,HORIZ_DIR,4); outtextxy(330,390,"Enter Your Choice "); int choice; cin>>choice; switch(choice) {

case 1: c: clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(midx,40,"Administrator Menu"); settextstyle(5,HORIZ_DIR,4); setcolor(1); outtextxy(midx-50,midy-100," Enter OLD Password "); gets(buf2); ptr=strcmpi(buf2,buf1);

72

Page 73: Hostel Report 1

if(ptr==0) {

setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(midx,40,"Administrator Menu"); settextstyle(5,HORIZ_DIR,4); setcolor(1); outtextxy(midx-50,150," Enter NEW Password "); gets(buf1); clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(midx,40,"Administrator Menu"); settextstyle(5,HORIZ_DIR,4); setcolor(1); outtextxy(midx,150," Re-Enter NEW Password "); gets(buf3); ptr=strcmpi(buf3,buf1); if(ptr==0) goto a; else goto c;

} else

{ clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(midx,40," Administrator Menu"); settextstyle(5,HORIZ_DIR,4); setcolor(1); outtextxy(midx,150," 1.Re-enter Password "); outtextxy(midx,185," 2.Back To Main Menu "); outtextxy(midx,390," Enter Your Choice"); cin>>choice; if(choice==1)

goto c;

73

Page 74: Hostel Report 1

else

goto a;

} break; case 2: goto a; break; default: clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(5,HORIZ_DIR,6); outtextxy(midx-50,midy-100," Invalid Choice "); delay(2000); goto d; break; } // end of switch(choice)

} // end of if(ptr==0)

else { clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(6,HORIZ_DIR,6); outtextxy(midx,40," Administrator Menu"); settextstyle(3,HORIZ_DIR,4); setcolor(1); outtextxy(midx,150," 1.Re-enter Password "); outtextxy(midx,185," 2.Back To Main Menu "); settextstyle(5,HORIZ_DIR,4); outtextxy(midx,390," Enter Your Choice"); int choice; cin>>choice; if(choice==1) goto h; else goto a; } // end of else statement

break; // end of case 2

74

Page 75: Hostel Report 1

//************** CHOICE 3. ******************//

case 3:

clrscr(); setbkcolor(2); cleardevice(); settextstyle(2,HORIZ_DIR,26); outtextxy(midx,midy,"...Bye Bye..."); delay(2500); closegraph(); cleardevice(); exit(0); break; // end of case 3

default: clrscr(); setbkcolor(3); bar(left,top,right,bottom); setcolor(4); settextstyle(3,HORIZ_DIR,6); outtextxy(midx,midy," Invalid Choice "); delay(2000); goto a; break;

} // end of switch(mchoice) file.close(); exit (0); closegraph(); cleardevice();} //end of main

75

Page 76: Hostel Report 1

References

76

Page 77: Hostel Report 1

References

Books

Balagutusamy, E. Object Oriented Programming with C++, New Delhi: Tata

McGraw-Hill Publishing Company Ltd, 2006.

Kanitkar, Yashwant. Let us C++. New Delhi: Danpat Rai Publication, 2005.

Websites

http://en.wikepedia.org/wiki/systems_analysis

http://www.nos.org/htm/sad1.htm

77

Page 78: Hostel Report 1

PART II[Seminar Report]

System

Analysis

&

Design

System Analysis and Design

78

Page 79: Hostel Report 1

 

INTRODUCTION

Systems are created to solve problems. One can think of the systems approach as an organized way of dealing with a problem. In this dynamic world, The subject System Analysis and Design, mainly deals with the software development activities.

Defining A System

A collection of components that work together to realize some objective forms a system.

Input, processing and output.

In a system the different components are connected with each other and they are interdependent.

For example, Human body represents a complete natural system. We are also bound by many national systems such as political system, economic system, educational system and so forth. The objective of the system demands that some output is produced as a result of processing the suitable inputs.

SYSTEM LIFE CYCLE

System life cycle is an organizational process of developing and maintaining systems. It helps in establishing a system project plan, because it gives overall list of processes and sub-processes required developing a system.

System development life cycle means combination of various activities. In other words we can say that various activities put together are referred as system development life cycle. In the System Analysis and Design terminology, the system development life cycle means software development life cycle.

79

Page 80: Hostel Report 1

Following are the different phases of software development cycle:

System study

Feasibility study

System analysis

System design

Coding

Testing

Implementation

Maintenance

 

Different phases of Software development Life Cycle

80

Page 81: Hostel Report 1

APPROACHES TO SYSTEM DEVELOPMENT

Process-Oriented Approach– Focus is on flow, use and transformation of data in an information system

– Involves creating graphical representations such as data flow diagrams and charts

– Data are tracked from sources, through intermediate steps and to final destinations

– Natural structure of data is not specified

– Disadvantage: data files are tied to specific applications

Data-Oriented Approach– Depicts ideal organization of data, independent of where and how data are

used

– Data model describes kinds of data and business relationships among the data

– Business rules depict how organization captures and processes the data

Process Approach:

“Let’s look at all of our processes. Processes take precedence over data. Get the processes correct first. Then we’ll address what data is important.”

Data Approach:

81

Page 82: Hostel Report 1

“Forget the processes, let’s look at the data. Data comes first. Get the data correct, then see how the processes actually use the data.”

82

Page 83: Hostel Report 1

PHASES OF SYSTEM DEVELOPMENT LIFE CYCLE

Let us now describe the different phases and the related activities of system development life cycle in detail.

(a) System Study

System study is the first stage of system development life cycle. This gives a clear picture of what actually the physical system is? In practice, the system study is done in two phases. In the first phase, the preliminary survey of the system is done which helps in identifying the scope of the system. The second phase of the system study is more detailed and in-depth study in which the identification of user’s requirement and the limitations and problems of the present system are studied. After completing the system study, a system proposal is prepared by the System Analyst (who studies the system) and placed before the user. The proposed system contains the findings of the present system and recommendations to overcome the limitations and problems of the present system in the light of the user’s requirements.

To describe the system study phase more analytically, we would say that system study phase passes through the following steps:

problem identification and project initiation background analysis inference or findings

(b) Feasibility Study

On the basis of result of the initial study, feasibility study takes place. The feasibility study is basically the test of the proposed system in the light of its workability, meeting user’s requirements, effective use of resources and .of course, the cost effectiveness. The main goal of feasibility study is not to solve the problem but to achieve the scope. In the process of feasibility study, the cost and benefits are estimated with greater accuracy.

(c) System Analysis

Assuming that a new system is to be developed, the next phase is system analysis. Analysis involved a detailed study of the current system, leading to specifications of a new system. Analysis is a detailed study of various operations performed by a system and their relationships within and outside the system. During analysis, data are collected on the available files, decision points and transactions handled by the present system. Interviews, on-site observation and questionnaire are the tools used for system analysis.

83

Page 84: Hostel Report 1

Using the following steps it becomes easy to draw the exact boundary of the new system under consideration:

Keeping in view the problems and new requirements Workout the pros and cons including new areas of the system

All procedures, requirements must be analysed and documented in the form of detailed data flow diagrams (DFDs), data dictionary, logical data structures and miniature specifications. System Analysis also includes sub-dividing of complex process involving the entire system, identification of data store and manual processes.

The main points to be discussed in system analysis are:

Specification of what the new system is to accomplish based on the user requirements.

Functional hierarchy showing the functions to be performed by the new system and their relationship with each other.

Function network which are similar to function hierarchy but they highlight the those functions which are common to more than one procedure.

List of attributes of the entities - these are the data items which need to be held about each entity (record)

(d) System Design

Based on the user requirements and the detailed analysis of a new system, the new system must be designed. This is the phase of system designing. It is a most crucial phase in the development of a system. Normally, the design proceeds in two stages :

preliminary or general design Structure or detailed design

Preliminary or general design: In the preliminary or general design, the features of the new system are specified. The costs of implementing these features and the benefits to be derived are estimated. If the project is still considered to be feasible, we move to the detailed design stage.

Structure or Detailed design: In the detailed design stage, computer oriented work begins in earnest. At this stage, the design of the system becomes more structured. Structure design is a blue print of a computer system solution to a given problem having the same components and inter-relationship among the same components as the original problem. Input, output and processing specifications are drawn up in detail. In the design stage, the programming language and the platform in which the new system will run are also decided.

There are several tools and techniques used for designing. These tools and techniques are:

84

Page 85: Hostel Report 1

Flowchart Data flow diagram (DFDs) Data dictionary Structured English Decision table Decision tree

Each of the above tools for designing will be discussed in detailed in the next lesson.

(e) Coding

After designing the new system, the whole system is required to be converted into computer understanding language. Coding the new system into computer programming language does this. It is an important stage where the defined procedure are transformed into control specifications by the help of a computer language. This is also called the programming phase in which the programmer converts the program specifications into computer instructions, which we refer as programs. The programs coordinate the data movements and control the entire process in a system.

It is generally felt that the programs must be modular in nature. This helps in fast development, maintenance and future change, if required.

(f) Testing

Before actually implementing the new system into operations, a test run of the system is done removing all the bugs, if any. It is an important phase of a successful system. After codifying the whole programs of the system, a test plan should be developed and run on a given set of test data. The output of the test run should match the expected results.

Using the test data following test run are carried out:

Unit test System test

Unit test: When the programs have been coded and compiled and brought to working conditions, they must be individually tested with the prepared test data. Any undesirable happening must be noted and debugged (error corrections).

System Test: After carrying out the unit test for each of the programs of the system and when errors are removed, then system test is done. At this stage the test is done on actual data. The complete system is executed on the actual data. At each stage of the execution, the results or output of the system is analysed. During the result analysis, it may be found that the outputs are not matching the expected out of the system. In such case, the errors in the particular programs are identified and are fixed and further tested for the expected output.

85

Page 86: Hostel Report 1

When it is ensured that the system is running error-free, the users are called with their own actual data so that the system could be shown running as per their requirements.

(g) Implementation

After having the user acceptance of the new system developed, the implementation phase begins. Implementation is the stage of a project during which theory is turned into practice. During this phase, all the programs of the system are loaded onto the user's computer. After loading the system, training of the users starts. Main topics of such type of training are:

How to execute the package How to enter the data How to process the data (processing details) How to take out the reports

After the users are trained about the computerized system, manual working has to shift from manual to computerized working. The following two strategies are followed for running the system:

i. Parallel run: In such run for a certain defined period, both the systems i.e. computerized and manual are executed in parallel. This strategy is helpful because of the following:

o Manual results can be compared with the results of the computerized system.

o Failure of the computerized system at the early stage, does not affect the working of the organization, because the manual system continues to work, as it used to do.

i. Pilot run: In this type of run, the new system is installed in parts. Some part of the new system is installed first and executed successfully for considerable time period. When the results are found satisfactory then only other parts are implemented. This strategy builds the confidence and the errors are traced easily.

(h) Maintenance

Maintenance is necessary to eliminate errors in the system during its working life and to tune the system to any variations in its working environment. It has been seen that there are always some errors found in the system that must be noted and corrected. It also means the review of the system from time to time. The review of the system is done for:

knowing the full capabilities of the system knowing the required changes or the additional requirements studying the performance

86

Page 87: Hostel Report 1

If a major change to a system is needed, a new project may have to be set up to carry out the change. The new project will then proceed through all the above life cycle phases.

Alternatives to SDLC

Prototyping

Prototyping is the process of quickly putting together a working model (a prototype) in order to test various aspects of a design, illustrate ideas or features and gather early user feedback. Prototyping is often treated as an integral part of the system design process, where it is believed to reduce project risk and cost. Often one or more prototypes are made in a process of incremental development where each prototype is influenced by the performance of previous designs, in these way problems or deficiencies in design can be corrected. When the prototype is sufficiently refined and meets the functionality, robustness, manufacturability and other design goals, the product is ready for production.

Pros

May provide the proof of concept necessary to attract funding Early visibility of the prototype gives users an idea of what the final system looks

like Encourages active participation among users and producer Enables a higher output for user Cost effective (Development costs reduced) Increases system development speed Assists to identify any problems with the efficacy of earlier design, requirements

analysis and coding activities Helps to refine the potential risks associated with the delivery of the system being

developed

Cons

User’s expectation on prototype may be above its performance Possibility of causing systems to be left unfinished Possibility of implementing systems before they are ready. Producer might produce a system inadequate for overall organization needs Producer might get too attached to it (might cause legal involvement) Often lack flexibility Not suitable for large applications Project management difficulties

87

Page 88: Hostel Report 1

Rapid application development (RAD)

Rapid application development (RAD), is a software development process developed initially by James Martin in the 1980s. The methodology involves iterative development, the construction of prototypes, and the use of Computer-aided software engineering (CASE) tools. Traditionally the rapid application development approach involves compromises in usability, features, and/or execution speed.

Pros

1. Increased speed of development through methods including rapid prototyping, virtualization of system related routines, the use of CASE tools, and other techniques.

2. Decreased end-user functionality (arising from narrower design focus), hence reduced complexity

3. Larger emphasis on simplicity and usability of GUI design

Cons

1. Reduced Scalability, and reduced features when a RAD developed application starts as a prototype and evolves into a finished application

2. Reduced features occur due to time boxing when features are pushed to later versions in order to finish a release in a short amount of time.

Joint Application Design (JAD)

Joint Application Design (JAD) is process used in the Systems Development Life Cycle (SDLC) to collect business requirements while developing new information systems for a company. It consists of a workshop where “knowledge workers and IT specialists meet, sometimes for several days, to define and review the business requirements for the system.1” This acts as a, “a management process which allows Corporate Information Services (IS) departments to work more effectively with users in a shorter time frame.2”

Through JAD workshops the knowledge workers and IT specialists are able to resolve any difficulties or differences between the two parties regarding the new information system. The workshop follows a detailed agenda in order to guarantee that all uncertainties between parties are covered and to help prevent any miscommunications. Miscommunications can carry far more serious repercussions if not addressed until later on in the process. (See below for Key Participants and Key Steps to an Effective JAD). In

88

Page 89: Hostel Report 1

the end, this process will result in a new information system that is feasible and appealing to both the designers and end users.

89