slam book - a computer science project

17
cout<< Book [Punit Goswami] {Computer Science} By

Upload: punit-goswami

Post on 16-Apr-2015

390 views

Category:

Documents


38 download

DESCRIPTION

This is a computer science project which emulates or work likes a slam book. It uses concepts of database file handling and modulation. The code is in the project file itself. Please remember to watch for the change in the credentials.

TRANSCRIPT

Page 1: Slam Book - A Computer Science Project

cout<<”

Book

By

Page 2: Slam Book - A Computer Science Project

1

TABLE OF CONTENTS | SLAM BOOK

CHAPTER 1 | PREFA CE

SECTION 1.1 CERTIFICATE

SECTION 1.2 ACKNOWLEDGEMENT

CHAPTER 2 | THE PROJECT

SECTION 2.1 INTRODUCTION TO THE PROGRAM

SECTION 2.2 METHODOLOGY ADOPTED

SECTION 2.3 SOURCE CODE

CHAPTER 3 | BIBLIOGRAPHY

SECTION 3.1 REFRENCES

SECTION 3.2 LINKS

Page 3: Slam Book - A Computer Science Project

2

TCertificatehis is to certify that Punit Goswami of class 12th B has satisfactorily completed the project in Computer Science in the academic year 2012-13. I have examined the project and hereby accord my approval of it as a study carried out and presented in the manner required for its acceptance. This does not necessarily endorse or accept every statement made or opinion expressed or conclusion drawn, but only signifies the acceptance of the project for the purpose it is submitted for.

Mrs Shalini Singh Dr Shalini Dixit

PGT (Computer Science) Principal, K.V. Manauri

AcknowledgementI hereby acknowledge my deep sense of gratitude

and indebtedness to Mrs Shalini Singh, PGT (Computer Science) whose immense help, genius guidance,

encouragement, necessary

Page 4: Slam Book - A Computer Science Project

3

suggestions, initiations, enthusiasm and inspiration made this work a master art and a joint enterprise.

INTRODUCTION 1|ONE

OBJECTIVE 1|ONE

Slam books are a personal memoir to the one which it belongs. It is filled by friends, close pals, near and dear ones. It not only gives brief information about them, like their phone no., email address or zodiac sign but it also lists what qualities they like in you and what would they wish for your future.

Slam books are, more or less, a way to look back on the way people considered a person, in the form of the treasured memories.

TECHNICAL OVERVIEW 2|TWO

C++ can be used to build a program to build a system which emulates a slam book. Though it won’t be visually much appealing, but the code line interface can be used to take the inputs and save them in a data file.

Individual data entries can be saved as data objects and further modification can be allowed through distributing the program into suitable cohesive modules.

Objective Method Code

Page 5: Slam Book - A Computer Science Project

4

main ( )

slamin ( )

show ( )

modify ( )

adios ( )

To ensure providing the authority to eligible modifiers only, a token or a password could be supplied to every user who makes an entry. There should also be a way to see the data entries without making any new entry. Error handling steps should also be dealt with, in case a faulty input is made by any novice user.

Henceforth, data entries will be referred to as ‘Slams’.

METHODOLOGY 2|TWO

The Slam Book program will use the input and output streams (i.e. iostream) to get the input from the user and to show the output to the user, respectively. The data file handling streams, i.e. fstream, ifstream and ofstream to save, access and modify the statically stored data. The static data will be stored in text files with ‘.dat’ extension.

In addition to these, predefined library files for handling strings (string.h & stdio.h), the exit controls (process.h) and for screen formatting (conio.h) will be used to make the program more appealing.

The program would be distributed into five programs to do the different tasks in the program:

a)slamin( )to make a new slam.b)show( ) to show the previous slams.c) modify( ) to let the user modify his/her slam.d)adios( ) to ask for a final consent while exiting the

program.e)main( ) to bind all the other functions.

Data structure with the name “slam” will be used to make a cohesive slam for a single

Page 6: Slam Book - A Computer Science Project

5

user; another structure with the name “date” will be used to define dates. Loops will be used to provide a menu like interface in the main( ) function, which will further call the other functions to the respective jobs as mentioned above.

Page 7: Slam Book - A Computer Science Project

6

SOURCE CODE THREE|3 /////////////////////////////////////////////// /// /// /// Slam Book Program // by Punit Goswami /// /// ///////////////////////////////////////////////////#include<stdio.h>#include<process.h>#include<conio.h>#include<fstream.h>#include<string.h>struct date{int d,m,y;};struct slam{ char name[36],nick[30],zodiac[15],hobbies[180],

number[11],quals[200],l4u[300],email[50],addr[100];char code[6];date dob;

}s1;void slamin(); //to enter a new slamvoid show(); //to show older slamsvoid modify(); //to modify an old slamvoid adios(); //to exitvoid main(){ char op;cout<<"\n\n\n\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~$$$$$$$$$$$$$$$$$$$$$$$$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

<<"\n\t\t\t\v WELCOME TO MY SLAM BOOK!!! \v" <<"\n\t\t\t\t\t_-_ Punit Goswami \n\n" <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~$$$$$$$$$$$$$$$$$$$$$$$

$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";getch();start:;

do{ clrscr();cout<<"\n\n\n\n\t\t\t\t/-----------------------\\"

<<"\n\t\t\t { Slam Menu... }" <<"\n\t\t\t\t\\-----------------------/\n" <<"\n\t\t\t\t| 1.| Fill my slam! |" <<"\n\n\t\t\t\t| 2.| Modify your slam |" <<"\n\n\t\t\t\t| 3.| See my slams |" <<"\n\n\t\t\t\t| 4.| Bid good bye! |" <<"\n\t\t\t\t/----------------------\\"

Page 8: Slam Book - A Computer Science Project

7

<<"\n\t\t\t\t[ SELECT A NUMBER ]\n\t\t\t\t\t";cin>>op;if(op =='1' )slamin();else if(op == '2')

modify();else if(op == '3')

show();else if(op == '4')

adios();else{cout<<"\n\t\tWrong choice chap!!

<<"\n\t\t\tPlease see the options carefully and try again." ;getch(); goto start;

}}while(1); exit(0);

}

void slamin(){ clrscr();

ofstream fo("slam.dat",ios::app);// file opened in append mode to protect previous data

cout<<"\n\n\n\tWhat's your name? ";gets(s1.name); clrscr();

cout<<"\n\n\n\tWhat do your friends call you? ";gets(s1.nick); clrscr();

cout<<"\n\n\n\tWhen were you born ? (dd mm yyyy) ";cin>>s1.dob.d>>s1.dob.m>>s1.dob.y; clrscr();

cout<<"\n\n\n\tWhat's your zodiac sign? ";gets(s1.zodiac); clrscr();

cout<<"\n\n\n\tAny hobbies ? ";gets(s1.hobbies); clrscr();

cout<<"\n\n\n\tYour mobile no. please... ";gets(s1.number); clrscr();

cout<<"\n\n\n\tPostal address.. ";gets(s1.addr); clrscr();

cout<<"\n\n\n\tEmail address... ";gets(s1.email); clrscr();

cout<<"\n\n\n\tWhich qualities do you like in me ? ";gets(s1.quals); clrscr();

cout<<"\n\n\n\tSome lines for me please!\n";gets(s1.l4u);

Page 9: Slam Book - A Computer Science Project

8

clrscr();cout<<"\n\n\n\n\tPlease enter a four character code { **** }.\n\t"

<<" This will allow you to modify \n" <<"your slam later ";

gets(s1.code);cout<<"\tPress to continue ";getch();

fo.write((char*)&s1,sizeof(s1));cout<<"\n\n\n\n\t\t\t\t "

<<":-)" <<"\n\t\t Slam added !!!\n\nPress any key to continue...::|" ;

getche();fo.close();

}

void modify(){ clrscr(); char found = 'n',name[26],cd[5]; long pos;

fstream fi("slam.dat",ios::in);cout<<"\n\tYour name ";gets(name);cout<<"\n\n\t\t\tYour code please";gets(cd); while(!fi.eof()) { pos = fi.tellg();

fi.read((char*)&s1,sizeof(s1));if((strcmp(s1.code,cd)== 0) &&(strcmpi(name,s1.name)==0)){ found = 'y'; clrscr();cout<<"Name "<<s1.name<<"\nnick name "<<s1.nick

<<"\n\nI was born on "<<s1.dob.d<<" "<<s1.dob.m<<" "<<s1.dob.y

<<"\t\tMy Star Sign is "<<s1.zodiac <<"\n\n\t I like "<<s1.hobbies<<"\n\n\t Ring me at "<<s1.number <<"\n\nI live at "<<s1.addr<<"\n\n Mail me at "<<s1.email <<"\n\n Things I like about you..\n "<<s1.quals <<"\n\n ... \""<<s1.l4u<<"\"\nLines"<<s1.code;

cout<<"\n\n\tEnter the new details...\n";slam save;

cout<<"\n\tName? (Enter '.'to retain old one)";gets(save.name); clrscr();cout<<"\n\tWhat do your friends call you? (Enter '.'to retain old one)";gets(save.nick); clrscr();cout<<"\n\tWhen were you born ? (Enter '0 0 0'to retain old one)";

cin>>save.dob.d>>save.dob.m>>save.dob.y; clrscr();

Page 10: Slam Book - A Computer Science Project

9

cout<<"\n\tEnter your zodiac sign: (Enter '.'to retain old one)";gets(save.zodiac); clrscr();cout<<"\n\tAny hobbies ? (Enter '.'to retain old one)";gets(save.hobbies); clrscr();cout<<"\n\tYour mobile no. please... (Enter '.'to retain old one)";gets(save.number); clrscr();cout<<"\n\tPostal address.. (Enter '.'to retain old one)";gets(save.addr); clrscr();cout<<"\n\tEmail address... (Enter '.'to retain old one)";gets(save.email); clrscr();cout<<"\n\tWhich qualities do you like in me ? (Enter '.'to retain old one)";gets(save.quals); clrscr();cout<<"\n\tSome lines for me please!(Enter '.'to retain old one)\n";gets(save.l4u); clrscr();cout<<"\n\n\n\nPlease enter a four number-code (****)."

<<" This will allow you to modify \n" <<"your slam later (Enter '.'to retain old one)";

cin>>save.code;if(strcmp(".",save.name)!= 0)

strcpy(s1.name,save.name);if(strcmp(".",save.nick)!= 0)

strcpy(s1.nick,save.nick);if(strcmp(".",save.zodiac)!= 0)

strcpy(s1.zodiac,save.zodiac);if(strcmp(".",save.hobbies)!= 0)

strcpy(s1.hobbies,save.hobbies);if(strcmp(".",save.number)!= 0)

strcpy(s1.number,save.number);if(strcmp(".",save.addr)!= 0)

strcpy(s1.addr,save.addr);if(strcmp(".",save.email)!= 0)

strcpy(s1.email,save.email);if(strcmp(save.quals,".")!= 0)

strcpy(s1.quals,save.quals);if(strcmp(save.l4u,".")!= 0)

strcpy(s1.l4u,save.l4u);if(strcmp(save.code,".")!= 0)

strcpy(s1.code,save.code);if(save.dob.d!= 0)

{s1.dob.d = save.dob.d;s1.dob.m = save.dob.m;s1.dob.y = save.dob.y; }

fi.seekp(pos);fi.write((char*)&save,sizeof(save));

Page 11: Slam Book - A Computer Science Project

10

break;} } if(found == 'n') {cout<<"Code not found!!"; getch();} fi.close();

}

void show(){ clrscr();

cout<<"\n--------------------------------------------------------------------------------" <<"|#\t\t\t\tPunit's Slam Book #|" <<"--------------------------------------------------------------------------------";ifstream fi("slam.dat",ios::in) ;while(fi.read((char*)&s1,sizeof(s1))){cout<<"\n"<<s1.name<<" ( "<<s1.email<<" )\n\nFriends call me

"<<s1.nick <<"\n\nI was born on "<<s1.dob.d<<"

"<<s1.dob.m<<" "<<s1.dob.y<<"\t\tMy Star Sign is "<<s1.zodiac <<"\n\n\t I like "<<s1.hobbies<<"\n\n\t Ring me

at "<<s1.number <<"\n\nI live at "<<s1.addr <<"\n\n Things I like about you..\n "<<s1.quals <<"\n\n \"... "<<s1.l4u<<" ...\"" <<"\

n~~~~~~~~~~~~~~~~~~~~~~~~~~~$$$$$$$$$$$$$$$$$$$$$$$$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";

cout<<"Press a key to see next slam -->\n";getch();}

clrscr();cout<<"\n\n\n\n\t No more slams !...\n\t\t Press any key to return \n\n\

n\n\t\t\t\t\t<--"; getch();}

void adios(){ clrscr(); char ch;

cout<<"\n\n\n\n\t\t\t ///////////////////////////////////////////" <<"\n\t\t\t //// /////" <<"\n\t\t\t //// Really wanna quit ? .. (y / n) ///// " <<"\n\t\t\t //// ///// " <<"\n\t\t\t///////////////////////////////////////////" <<"\n\t\t\t // //\n\t\t\t\t " ;

Page 12: Slam Book - A Computer Science Project

11

cin>>ch; if(ch=='y'||ch=='Y')

exit(0);

}

SCREEN SHOTS FOUR|4

Page 13: Slam Book - A Computer Science Project

12

Page 14: Slam Book - A Computer Science Project

13

BibliographyREFERENCES ONE|1

o Computer Science with C++ by Sumita Arorao Guide of Reference to C++ by Tata-McGraw Hill

LINKS TWO|2

o www.cs76.net

o www.github.google.com

o www.thinkdigit.com