CD
MANAGEMENT
C++ CODING
CLASS 12TH
PROJECT
VIDHI KISHOR
12TH F
Mr. SANJEEV
1
2 | P a g e
This project was made by VIDHI KISHOR
of class XII-F and I would like to express
my sincere gratitude to my computer
science teacher Mr. Sanjeev, for his vital
support, guidance and encouragement
without which this project would not have
come forth.
I would also like to express my gratitude to
the school and to the Principal,
Dr. V.K Williams for letting me use the
school laboratory and for providing me
with an environment to complete my
project successfully.
Finally, I take this opportunity to extend
my deep appreciation to my family and
friends, for all that they meant to me
during the crucial times of the completion
of my project.
2
3 | P a g e
No. Title
1. Objective of the Project
2. Working of the Program
3. Structure Charts
• Class CD
• void main( )
4. Program Flow Charts
5. Classes and Functions Used
6. Program Coding
7. Sample Outputs
8. Bibliography 2
4 | P a g e
OBJECTIVE
This software is basically a CD Management
Software which can be used in a CDs Store. It
keeps the record of all the CDs present in the
CDs Store and we can also add more records
for the fresh arrivals. This project can search
the CDs available in the store, by various
modes like Singer Name, CD Name, Release,
and cost. It also has a unique feature of
BACKUP to save all our records and also, if
anything goes wrong, then we can restore our
last backup file.
5 | P a g e
WORKING
This C++ project is based on CD Management System. This
program uses the concept of object-oriented programming and
data file handling. Database is a collection of interrelated data
to serve multiple applications. That is database programs create
files of information. So we see that files are worked with most,
inside the program.
The program helps us to perform several tasks that have
been explained in detail as below:
1) Adding the details of a New CD:
To perform this task the program uses the technique of
opening the existing “CD.dat” file for reading and a
“temp.dat” file for writing. The existing records are read
from the “CD.dat” file and are written in the “temp.dat” file.
The new record is added in the “temp.dat” file and both the
files are closed. The “CD.dat” file is then removed and the
“temp.dat” file is renamed to “CD.dat”. Thus a new record
is added at the end of the “CD.dat” file.
6 | P a g e
2) Modifying the data of an CD:
To perform this task the program uses the technique of
opening the existing “CD.dat” file for reading and a
“temp.dat” file for writing. The CD number to be modified is
inputted from the user. All the records are read from the
“CD.dat” file and each record’s employee number is
compared with the one supplied by the user. Every record,
after reading, is written into the “temp.dat” file except when
the CD number match is successful. When the match is
successful the user is asked to enter the new data. Then this
data is added to the “temp.dat” file. Both the files are then
closed. The “CD.dat” file is then removed and the
“temp.dat” file is renamed to “CD.dat”. Thus the required
CD record is modified from the “CD.dat” file.
3) Deleting a CD’s Details:
To perform this task the program uses the technique of
opening the existing “CD.dat” file for reading and a
“temp.dat” file for writing. The CD number to be deleted is
inputted from the user. The existing records are read from
the “CD.dat” file and each record’s CD number is compared
with the one supplied by the user. Every record, after
reading, is written into the “temp.dat” file except when the
CD number match is successful. Thus all the records except
for the one to be deleted are copied into the “temp.dat” file.
Both the files are then closed. The “CD.dat” file is then
removed and the “temp.dat” file is renamed to “CD.dat”.
7 | P a g e
Thus the required CD record is deleted from the “CD.dat”
file.
4) Searching for a CD:
To perform this task the program uses the technique of
opening the existing “CD.dat” file for reading. The detail to
be searched is inputted from the user. The CD records are
then read one by one from the “CD.dat” file and each
record’s CD detail is compared with the one supplied by the
user. On finding a match, the program displays the details of
that particular CD. Otherwise it displays that the reqd. CD’s
details does not exists. The files are then closed. Thus a
particular CD is searched for by the program.
5) Displaying the list of all CDs:
To perform this task the program uses the technique of
opening the existing “CD.dat” file for reading. The CD
records are then read one by one from the “CD.dat” file and
only the relevant details are displayed. The file is then
closed. Thus the list of all CDs is displayed.
8 | P a g e
STRUCTURE
CHARTS
9 | P a g e
Class CD
-The main CD
class. Used for
inputting and
displaying data.
Class CD
-The main CD
class. Used for
inputting and
displaying data.
accept()
-To input values.
accept()
-To input values.
display()
-To output
values.
display()
-To output
values.
Read()
- To read the data.
Read()
- To read the data.
rbno()
-To return CD no.
rbno()
-To return CD no.
Search()
-To search records.
Search()
-To search records.
*rbname()
-To return CD
name.
*rbname()
-To return CD
name.
shtype()
-To search by
type of CD.
shtype()
-To search by
type of CD.
searchbname()
-To search by
CD name.
searchbname()
-To search by
CD name.
shcost()
-To search by
cost.
shcost()
-To search by
cost.
shaname()
-To search by
singer’s name.
shaname()
-To search by
singer’s name.
10 | P a g e
shrelease()
-To search by
year of release.
shrelease()
-To search by
year of release.
Class CD
-The main CD
class. Used for
inputting and
displaying data.
Class CD
-The main CD
class. Used for
inputting and
displaying data.
write()
-To write records
in CD.dat.
write()
-To write records
in CD.dat.
update()
-To update
values.
update()
-To update
values.
backup()
-To create a
backup of all
records.
backup()
-To create a
backup of all
records.
del()
-To delete
records.
del()
-To delete
records.
restore()
-To restore all
records.
restore()
-To restore all
records.
menu()
-To display
search menu.
menu()
-To display
search menu.
mainmenu()
-To display main
menu.
mainmenu()
-To display main
menu.
FLOWCHART
11 | P a g e
START
ENTER PASSWORD
If (pwd = Value)
Choose the options
1. Add a Record
2. Display All the
Records
3. Modify a Record
4. Search a Record
5. Delete a Record
6. Create a Backup
7. Restore the Last
Backup File
8. Exit
Print “Invalid Password”
If Option = 8
Go To Particular Option
Go To Previous Menu EXIT
Choose the Search Option
1 Search by CD Number
2. Search by CD Name
3. Search by Singer Name
4. Search by Release
5. Search by Type
6. Search by Cost
7. Back to Previous Menu
8. Exit
If Option = 4
Go To Particular Option
Go To Previous Menu EXIT
If Option = 8
Print “Thank You
Have a Nice Day”STOP
Print “Thank You
Have a Nice Day”
Classes and Functions
Used
CLASSES:
• CD
MEMBER FUNCTIONS OF CLASS:
• rbno();
• *rbname();
• *ran();
• accept();
• accept1();
• read();
• search();
• searchbname();
• shaname();
• shtype();
• shcost();
• shrelease();
12 | P a g e
GLOBAL MEMBER FUNCTIONS OF CLASS:
• write();
• update();
• del();
• backup();
• restore();
• menu();
• mainmenu();
DATA FILES USED
• CD.dat (Original File Containing all data)
• temp.dat (A Temporary File for keeping
deleted data)
13 | P a g e
14 | P a g e
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<process.h>
#include<dos.h>
void mainmenu();
class CD
{
private:
int bno;
char bname[30];
char aname[30];
char type[10];
int nocopy;
char yredit[5];
float cost;
public:
CD()
{
bno=0;
nocopy=0;
cost=0;
}
int rbno() //for asscessing private member outside class
{
return bno;
}
char *rbname()
{
return bname;
}
char *ran()
{
return aname;
}
void accept()
{
clrscr();
int count=0;
fstream f1;
15 | P a g e
f1.open("CD.dat",ios::in|ios::binary);
while(f1.read((char*)this,sizeof(CD)))
count++;
if(count==0)
bno=1;
else
bno++;
f1.close();
cout<<"nEnter The CD Number:- "<<bno;
cout<<"nEnter The CD Title:- ";
gets(bname);
cout<<"nEnter Singer's Name:- ";
gets(aname);
cout<<"nEnter The Type of The CD:- ";
gets(type);
cout<<"nEnter No. of Copies:- ";
cin>>nocopy;
cout<<"nEnter Year of Release:- ";
cin>>yredit;
cout<<"nEnter the Cost of CD:- ";
cin>>cost;
}
void accept1()
{
cout<<"nEnter The CD Title:- ";
gets(bname);
cout<<"nEnter Singer's Name:- ";
gets(aname);
cout<<"nEnter The Type of The CD:- ";
gets(type);
cout<<"nEnter No. of Copies:- ";
cin>>nocopy;
cout<<"nEnter Year of Release:- ";
cin>>yredit;
cout<<"nEnter the Cost of The CD:- ";
cin>>cost;
}
void read();
void search();
void searchbname();
void shaname();
void shtype();
16 | P a g e
void shcost();
void shrelease();
};
void write()
{
fstream f1("CD.dat",ios::app|ios::binary);
CD e;
e.accept();
f1.write((char*)&e,sizeof(e));
cout<<"nRECORD ADDED SUCCESSFULLY!!!!!!!!!!n";
getch();
f1.close();
}
void CD::read()
{
clrscr() ;
fstream file ;
file.open("CD.dat",ios::in|ios::binary);
file.seekg(0) ;
int row = 5 , found = 0 , pageno = 1 ;
gotoxy(18,1) ;
cout<<"LIST OF CDS" ;
gotoxy(1,3) ;
cout<<"nCD No. CD Name Singer's Name Type Release
Sale Costnn";
while (file.read((char *) this, sizeof(CD)))
{
delay(50) ;
found = 1 ;
gotoxy(2,row) ;
cout<<bno;
gotoxy(14,row) ;
cout<<bname;
gotoxy(27,row) ;
cout<<aname;
gotoxy(42,row) ;
cout<<type;
gotoxy(55,row) ;
cout<<yredit;
gotoxy(66,row) ;
cout<<nocopy;
gotoxy(74,row) ;
17 | P a g e
cout<<cost;
if ( row == 23 )
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
pageno++ ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
cout<<"LIST OF CDS" ;
gotoxy(1,5) ;
cout<<"nCD No. CD Name Singer's Name Type
Release Sale Costnn";
}
else
row++ ;
}
if ( !found )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void update()
{
clrscr();
fstream f1("CD.dat",ios::in|ios::out|ios::binary);
CD e;
int n,flag=0,record=0;;
cout<<"nEnter CD No. to be Modifiedn";
cin>>n;
while(f1.read((char*)&e,sizeof(e)))
{
record++;
if(e.rbno()==n)
18 | P a g e
{
cout<<"nEnter New Valuesn";
e.accept1();
f1.seekp((record-1)*sizeof(e));
f1.write((char*)&e,sizeof(e));
cout<<"nnnnRecord Modified Sucessfullynnn";
getch();
flag=1;
break;
}
}
if(!flag)
cout<<"nRecord Not Found!!!!!!!n";delay(200);
f1.close();
}
void del()
{
clrscr();
fstream f1,f2;
f1.open("CD.dat",ios::in|ios::binary);
f2.open("temp.dat",ios::out|ios::binary);
CD e;
int n,flag=0;
cout<<"nEnter CD Number to be Deletedn";
cin>>n;
while(f1.read((char*)&e,sizeof(e)))
{
if(e.rbno()!=n)
f2.write((char*)&e,sizeof(e));
else
flag=1;
}
if(flag)
cout<<"nRecord Deleted!!!!!!!n";
else
cout<<"nRecord Not Found!!!!!n";getch();
f1.close();
f2.close();
remove("CD.dat");
rename("temp.dat","CD.dat");
}
void CD::search()
{
19 | P a g e
clrscr() ;
fstream file ;
file.open("CD.dat",ios::in|ios::binary);
file.seekg(0) ;
int n;
cout<<"nnEnter the CD number to be searchedn";
cin>>n;
clrscr();
int row = 5 , found = 0 , pageno = 1 ;
gotoxy(18,1) ;
cout<<"LIST OF CDS" ;
gotoxy(1,3) ;
cout<<"nCD No. CD Name Singer's Name Type Release
Sale Costnn";
while (file.read((char *) this, sizeof(CD)))
{
if(bno==n)
{
delay(50) ;
found = 1 ;
gotoxy(2,row) ;
cout<<bno;
gotoxy(14,row) ;
cout<<bname;
gotoxy(27,row) ;
cout<<aname;
gotoxy(42,row) ;
cout<<type;
gotoxy(55,row) ;
cout<<yredit;
gotoxy(66,row) ;
cout<<nocopy;
gotoxy(74,row) ;
cout<<cost;
if ( row == 23 )
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
pageno++ ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
20 | P a g e
cout<<"LIST OF CDS" ;
gotoxy(1,5) ;
cout<<"nCD No. CD Name Singer's Name Type
Release Sale Costnn";
}
else
row++ ;
} }
if ( !found )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void CD::searchbname()
{
clrscr() ;
fstream file ;
file.open("CD.dat",ios::in|ios::binary);
file.seekg(0) ;
char n[20];
cout<<"nnEnter the CD name to be searchedn";
gets(n);
clrscr();
int row = 5 , found = 0 , pageno = 1 ;
gotoxy(18,1) ;
cout<<"LIST OF CDS" ;
gotoxy(1,3) ;
cout<<"nCD No. CD Name Singer's Name Type Release
Sale Costnn";
while (file.read((char *) this, sizeof(CD)))
{
if(strcmpi(bname,n)==0)
{
delay(50) ;
found = 1 ;
gotoxy(2,row) ;
21 | P a g e
cout<<bno;
gotoxy(14,row) ;
cout<<bname;
gotoxy(27,row) ;
cout<<aname;
gotoxy(42,row) ;
cout<<type;
gotoxy(55,row) ;
cout<<yredit;
gotoxy(66,row) ;
cout<<nocopy;
gotoxy(74,row) ;
cout<<cost;
if ( row == 23 )
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
pageno++ ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
cout<<"LIST OF CDS" ;
gotoxy(1,5) ;
cout<<"nCD No. CD Name Singer's Name Type
Release Sale Costnn";
}
else
row++ ;
} }
if ( !found )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
22 | P a g e
}
void CD::shaname()
{
clrscr() ;
fstream file ;
file.open("CD.dat",ios::in|ios::binary);
file.seekg(0) ;
char n[20];
cout<<"Enter the singer's name whose CDs is to be searchedn";
gets(n);
clrscr();
int row = 5 , found = 0 , pageno = 1 ;
gotoxy(18,1) ;
cout<<"LIST OF CDS" ;
gotoxy(1,3) ;
cout<<"nCD No. CD Name Singer's Name Type Release
Sale Costnn";
while (file.read((char *) this, sizeof(CD)))
{
if(strcmpi(aname,n)==0)
{
delay(50) ;
found = 1 ;
gotoxy(2,row) ;
cout<<bno;
gotoxy(14,row) ;
cout<<bname;
gotoxy(27,row) ;
cout<<aname;
gotoxy(42,row) ;
cout<<type;
gotoxy(55,row) ;
cout<<yredit;
gotoxy(66,row) ;
cout<<nocopy;
gotoxy(74,row) ;
cout<<cost;
if ( row == 23 )
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
pageno++ ;
23 | P a g e
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
cout<<"LIST OF CDS" ;
gotoxy(1,5) ;
cout<<"nCD No. CD Name Singer's Name Type
Release Sale Costnn";
}
else
row++ ;
} }
if ( !found )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void CD::shtype()
{
clrscr() ;
fstream file ;
file.open("CD.dat",ios::in|ios::binary);
file.seekg(0) ;
char n[20];
cout<<"Enter the Type of CDs to searchedn";
gets(n);
clrscr();
int row = 5 , found = 0 , pageno = 1 ;
gotoxy(18,1) ;
cout<<"LIST OF CDS" ;
gotoxy(1,3) ;
cout<<"nCD No. CD Name Singer's Name Type Release
Sale Costnn";
while (file.read((char *) this, sizeof(CD)))
24 | P a g e
{
if(strcmpi(type,n)==0)
{
delay(50) ;
found = 1 ;
gotoxy(2,row) ;
cout<<bno;
gotoxy(14,row) ;
cout<<bname;
gotoxy(27,row) ;
cout<<aname;
gotoxy(42,row) ;
cout<<type;
gotoxy(55,row) ;
cout<<yredit;
gotoxy(66,row) ;
cout<<nocopy;
gotoxy(74,row) ;
cout<<cost;
if ( row == 23 )
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
pageno++ ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
cout<<"LIST OF CDS" ;
gotoxy(1,5) ;
cout<<"nCD No. CD Name Singer's Name Type
Release Sale Costnn";
}
else
row++ ;
} }
if ( !found )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
25 | P a g e
cout<<"Page no. : " <<pageno ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void CD::shrelease()
{
clrscr() ;
fstream file ;
file.open("CD.dat",ios::in|ios::binary);
file.seekg(0) ;
char n[20];
cout<<"Enter the Year of Release to be searchedn";
gets(n);
clrscr();
int row = 5 , found = 0 , pageno = 1 ;
gotoxy(18,1) ;
cout<<"LIST OF CDS" ;
gotoxy(1,3) ;
cout<<"nCD No. CD Name Singer's Name Type Release
Sale Costnn";
while (file.read((char *) this, sizeof(CD)))
{
if(strcmpi(yredit,n)==0)
{
delay(50) ;
found = 1 ;
gotoxy(2,row) ;
cout<<bno;
gotoxy(14,row) ;
cout<<bname;
gotoxy(27,row) ;
cout<<aname;
gotoxy(42,row) ;
cout<<type;
gotoxy(55,row) ;
cout<<yredit;
gotoxy(66,row) ;
cout<<nocopy;
gotoxy(74,row) ;
cout<<cost;
if ( row == 23 )
26 | P a g e
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
pageno++ ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
cout<<"LIST OF CDS" ;
gotoxy(1,5) ;
cout<<"nCD No. CD Name Singer's Name Type
Release Sale Costnn";
}
else
row++ ;
} }
if ( !found )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void CD::shcost()
{
clrscr() ;
fstream file ;
file.open("CD.dat",ios::in|ios::binary);
file.seekg(0) ;
int n;
cout<<"Enter the minimum cost to see the CDsn";
cin>>n;
clrscr();
int row = 5 , found = 0 , pageno = 1 ;
gotoxy(18,1) ;
27 | P a g e
cout<<"LIST OF CDS" ;
gotoxy(1,3) ;
cout<<"nCD No. CD Name Singer's Name Type Release
Sale Costnn";
while (file.read((char *) this, sizeof(CD)))
{
if(cost>n)
{
delay(50) ;
found = 1 ;
gotoxy(2,row) ;
cout<<bno;
gotoxy(14,row) ;
cout<<bname;
gotoxy(27,row) ;
cout<<aname;
gotoxy(42,row) ;
cout<<type;
gotoxy(55,row) ;
cout<<yredit;
gotoxy(66,row) ;
cout<<nocopy;
gotoxy(74,row) ;
cout<<cost;
if ( row == 23 )
{
row = 5 ;
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
pageno++ ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
clrscr() ;
cout<<"LIST OF CDS" ;
gotoxy(1,5) ;
cout<<"nCD No. CD Name Singer's Name Type
Release Sale Costnn";
}
else
row++ ;
}
}
28 | P a g e
if ( !found )
{
gotoxy(1,5) ;
cout<<"Records not found" ;
}
gotoxy(66,1) ;
cout<<"Page no. : " <<pageno ;
gotoxy(1,25) ;
cout<<"Press any key to continue..." ;
getch() ;
file.close () ;
}
void backup()
{
char ch;
cout<<"n Are You Sure That You Want To Create A Backup?
(y/n)n";
cin>>ch;
if(ch=='y')
{
CD e;
fstream f1,f2;
f1.open("CD.dat",ios::in|ios::binary);
f2.open("susa.dat",ios::out|ios::binary);
while(f1.read((char*)&e,sizeof(e)))
{
f2.write((char*)&e,sizeof(e));
}
f1.close();
f2.close();
}
cout<<"nnBackup Created!!!!!!";getch();
}
void restore()
{
char ch;
cout<<"n Are You Sure You Want to Restore The Last Backup File?
(y/n)n";
cin>>ch;
if(ch=='y')
{
29 | P a g e
remove("CD.dat");
rename("susa.dat","CD.dat");
cout<<"nnBackup File Restored....";
}
else
cout<<"nFile not Restored!!!!nn";
}
void menu()
{
char ch1;
CD b;
int ch;
while(1)
{
clrscr();
cout<<"nnntt****************************************n";
cout<<"nttt Search Menun";
cout<<"ntt****************************************n";
cout<<"ttt1. Search by CD Numbernttt2. Search by CD Namen"
<<"ttt3. Search by Singer Namenttt4. Search by Releasen"
<<"ttt5. Search by Typenttt6. Search by Costn"
<<"ttt7. Back to Previous Menunttt8. Exitn";
cout<<"ntt****************************************n";
cout<<"nnnttEnter your choice: ";
gotoxy(35,22);
cin>>ch;
switch(ch)
{
case 1:
b.search();
break;
case 2:
b.searchbname();
break;
case 3:
b.shaname();
break;
case 4:
b.shrelease();
break;
case 5:
b.shtype();
break;
30 | P a g e
case 6:
b.shcost();
break;
case 7:
mainmenu();
break;
case 8:
exit(0);
default:
cout<<"nnnInvalid Choicennn";
}
}
}
void mainmenu()
{
int ch;
char ch1;
CD b;
while(1)
{
clrscr();
cout<<"nnnnnnnnntt
****************************************nn";
cout<<"tt****** M . A . I . N - M . E . N . U *******n";
cout<<"ntt ****************************************n";
cout<<"nttt1. Add a Recordnttt2. Display All The Recordsn"
<<"ttt3. Modify a Recordnttt4. Search a Recordn"
<<"ttt5. Delete a Recordnttt6. Create a Backupn"
<<"ttt7. Restore the Last Backup Filenttt8. Exitn";
cout<<"ntt ****************************************n";
cout<<"nnntt Enter Your Choice: ";
gotoxy(38,29);
cin>>ch;
switch(ch)
{
case 1:
write();
break;
case 2:
b.read();
break;
case 3:
update();
break;
31 | P a g e
case 4:
menu();
break;
case 5:
del();
break;
case 6:
backup();
break;
case 7:
restore();
break;
case 8:
{ clrscr();
gotoxy(26,10);
delay(200);
cout<<"T";
delay(100);
cout<<"h";
delay(100);
cout<<"a";
delay(100);
cout<<"n";
delay(100);
cout<<"k";
delay(100);
cout<<" Y";
delay(50);
cout<<"o";
delay(100);
cout<<"u";
delay(100);
cout<<" F";
delay(100);
cout<<"o";
delay(100);
cout<<"r";
delay(100);
cout<<" V";
delay(100);
cout<<"i";
delay(100);
cout<<"s";
delay(100);
32 | P a g e
cout<<"i";
delay(100);
cout<<"t";
delay(100);
cout<<"i";
delay(100);
cout<<"n";
delay(100);
cout<<"g";
delay(50);
cout<<" O";
delay(100);
cout<<"u";
delay(100);
cout<<"r";
delay(100);
cout<<" P";
delay(100);
cout<<"r";
delay(100);
cout<<"o";
delay(100);
cout<<"j";
delay(100);
cout<<"e";
delay(100);
cout<<"c";
delay(100);
cout<<"t";
getch();
gotoxy(32,12);
cout<<" HAVE A NICE DAY " ;
getch();
exit(0);
}
default:
cout<<"nnnInvalid Choicennn";
}
}
}
void main()
{
33 | P a g e
clrscr();textcolor(GREEN);
char ch1;
int ch;
char pass[10];
gotoxy(30,15);
cout<<"Enter your Password : ";
gotoxy(55,15);
pass[0]=getch();
cout<<"*";
pass[1]=getch();
cout<<"*";
pass[2]=getch();
cout<<"*";
pass[3]=getch();
cout<<"*";
pass[4]=getch();
cout<<"*";
pass[5]='0';
getch();
CD b;
if(strcmpi(pass,"rajat")==0)
{
clrscr();
cout<<"nnnnnttttWELCOME TO OUR PROJECT
nnnnttttCD Management System n MUSIC WORLDn"
<<"nnnttt Made by:";
delay(200);
cout<<"R";
delay(100);
cout<<"A";
delay(100);
cout<<"J";
delay(100);
cout<<"A";
delay(100);
cout<<"T";
delay(100);
cout<<" ";
delay(50);
cout<<"S";
delay(100);
cout<<"A";
delay(100);
34 | P a g e
cout<<"H";
delay(100);
cout<<"N";
delay(100);
cout<<"I";
gotoxy(25,25);
cout<<" Press any Key to Continuen";
getch();
mainmenu();
}
else
cout<<"nnnnInvalid Password!!!!!!Try Again.....nnn";
getch();
}
35 | P a g e
SCREEN -1:
36 | P a g e
SCREEN -2:
SCREEN -3:
37 | P a g e
SCREEN -4:
SCREEN -5:
38 | P a g e
SCREEN -6:
39 | P a g e
SCREEN -7:
40 | P a g e
SCREEN -8:
41 | P a g e
SCREEN -9:
SCREEN -10:
42 | P a g e
43 | P a g e
SCREEN -11:
44 | P a g e
SCREEN -12:
45 | P a g e
SCREEN -13:
46 | P a g e
SCREEN -14:
47 | P a g e
SCREEN -15:
SCREEN -16:
48 | P a g e
SCREEN -17:
49 | P a g e
References taken from Sumita Arora (Computer Science Class
XII and XI)
1. Reeta Sahoo (Computer Science Class XII and XI)
2. Together with Class –XII
3. www.google.com
50 | P a g e

Computer project C++ CLASS 12TH (CD MANAGEMENT SYSTEM )

  • 1.
  • 2.
    VIDHI KISHOR 12TH F Mr.SANJEEV 1 2 | P a g e
  • 3.
    This project wasmade by VIDHI KISHOR of class XII-F and I would like to express my sincere gratitude to my computer science teacher Mr. Sanjeev, for his vital support, guidance and encouragement without which this project would not have come forth. I would also like to express my gratitude to the school and to the Principal, Dr. V.K Williams for letting me use the school laboratory and for providing me with an environment to complete my project successfully. Finally, I take this opportunity to extend my deep appreciation to my family and friends, for all that they meant to me during the crucial times of the completion of my project. 2 3 | P a g e
  • 4.
    No. Title 1. Objectiveof the Project 2. Working of the Program 3. Structure Charts • Class CD • void main( ) 4. Program Flow Charts 5. Classes and Functions Used 6. Program Coding 7. Sample Outputs 8. Bibliography 2 4 | P a g e
  • 5.
    OBJECTIVE This software isbasically a CD Management Software which can be used in a CDs Store. It keeps the record of all the CDs present in the CDs Store and we can also add more records for the fresh arrivals. This project can search the CDs available in the store, by various modes like Singer Name, CD Name, Release, and cost. It also has a unique feature of BACKUP to save all our records and also, if anything goes wrong, then we can restore our last backup file. 5 | P a g e
  • 6.
    WORKING This C++ projectis based on CD Management System. This program uses the concept of object-oriented programming and data file handling. Database is a collection of interrelated data to serve multiple applications. That is database programs create files of information. So we see that files are worked with most, inside the program. The program helps us to perform several tasks that have been explained in detail as below: 1) Adding the details of a New CD: To perform this task the program uses the technique of opening the existing “CD.dat” file for reading and a “temp.dat” file for writing. The existing records are read from the “CD.dat” file and are written in the “temp.dat” file. The new record is added in the “temp.dat” file and both the files are closed. The “CD.dat” file is then removed and the “temp.dat” file is renamed to “CD.dat”. Thus a new record is added at the end of the “CD.dat” file. 6 | P a g e
  • 7.
    2) Modifying thedata of an CD: To perform this task the program uses the technique of opening the existing “CD.dat” file for reading and a “temp.dat” file for writing. The CD number to be modified is inputted from the user. All the records are read from the “CD.dat” file and each record’s employee number is compared with the one supplied by the user. Every record, after reading, is written into the “temp.dat” file except when the CD number match is successful. When the match is successful the user is asked to enter the new data. Then this data is added to the “temp.dat” file. Both the files are then closed. The “CD.dat” file is then removed and the “temp.dat” file is renamed to “CD.dat”. Thus the required CD record is modified from the “CD.dat” file. 3) Deleting a CD’s Details: To perform this task the program uses the technique of opening the existing “CD.dat” file for reading and a “temp.dat” file for writing. The CD number to be deleted is inputted from the user. The existing records are read from the “CD.dat” file and each record’s CD number is compared with the one supplied by the user. Every record, after reading, is written into the “temp.dat” file except when the CD number match is successful. Thus all the records except for the one to be deleted are copied into the “temp.dat” file. Both the files are then closed. The “CD.dat” file is then removed and the “temp.dat” file is renamed to “CD.dat”. 7 | P a g e
  • 8.
    Thus the requiredCD record is deleted from the “CD.dat” file. 4) Searching for a CD: To perform this task the program uses the technique of opening the existing “CD.dat” file for reading. The detail to be searched is inputted from the user. The CD records are then read one by one from the “CD.dat” file and each record’s CD detail is compared with the one supplied by the user. On finding a match, the program displays the details of that particular CD. Otherwise it displays that the reqd. CD’s details does not exists. The files are then closed. Thus a particular CD is searched for by the program. 5) Displaying the list of all CDs: To perform this task the program uses the technique of opening the existing “CD.dat” file for reading. The CD records are then read one by one from the “CD.dat” file and only the relevant details are displayed. The file is then closed. Thus the list of all CDs is displayed. 8 | P a g e
  • 9.
    STRUCTURE CHARTS 9 | Pa g e Class CD -The main CD class. Used for inputting and displaying data. Class CD -The main CD class. Used for inputting and displaying data. accept() -To input values. accept() -To input values. display() -To output values. display() -To output values. Read() - To read the data. Read() - To read the data. rbno() -To return CD no. rbno() -To return CD no. Search() -To search records. Search() -To search records. *rbname() -To return CD name. *rbname() -To return CD name. shtype() -To search by type of CD. shtype() -To search by type of CD. searchbname() -To search by CD name. searchbname() -To search by CD name. shcost() -To search by cost. shcost() -To search by cost. shaname() -To search by singer’s name. shaname() -To search by singer’s name.
  • 10.
    10 | Pa g e shrelease() -To search by year of release. shrelease() -To search by year of release. Class CD -The main CD class. Used for inputting and displaying data. Class CD -The main CD class. Used for inputting and displaying data. write() -To write records in CD.dat. write() -To write records in CD.dat. update() -To update values. update() -To update values. backup() -To create a backup of all records. backup() -To create a backup of all records. del() -To delete records. del() -To delete records. restore() -To restore all records. restore() -To restore all records. menu() -To display search menu. menu() -To display search menu. mainmenu() -To display main menu. mainmenu() -To display main menu.
  • 11.
    FLOWCHART 11 | Pa g e START ENTER PASSWORD If (pwd = Value) Choose the options 1. Add a Record 2. Display All the Records 3. Modify a Record 4. Search a Record 5. Delete a Record 6. Create a Backup 7. Restore the Last Backup File 8. Exit Print “Invalid Password” If Option = 8 Go To Particular Option Go To Previous Menu EXIT Choose the Search Option 1 Search by CD Number 2. Search by CD Name 3. Search by Singer Name 4. Search by Release 5. Search by Type 6. Search by Cost 7. Back to Previous Menu 8. Exit If Option = 4 Go To Particular Option Go To Previous Menu EXIT If Option = 8 Print “Thank You Have a Nice Day”STOP Print “Thank You Have a Nice Day”
  • 12.
    Classes and Functions Used CLASSES: •CD MEMBER FUNCTIONS OF CLASS: • rbno(); • *rbname(); • *ran(); • accept(); • accept1(); • read(); • search(); • searchbname(); • shaname(); • shtype(); • shcost(); • shrelease(); 12 | P a g e
  • 13.
    GLOBAL MEMBER FUNCTIONSOF CLASS: • write(); • update(); • del(); • backup(); • restore(); • menu(); • mainmenu(); DATA FILES USED • CD.dat (Original File Containing all data) • temp.dat (A Temporary File for keeping deleted data) 13 | P a g e
  • 14.
    14 | Pa g e
  • 15.
    #include<fstream.h> #include<conio.h> #include<stdio.h> #include<string.h> #include<process.h> #include<dos.h> void mainmenu(); class CD { private: intbno; char bname[30]; char aname[30]; char type[10]; int nocopy; char yredit[5]; float cost; public: CD() { bno=0; nocopy=0; cost=0; } int rbno() //for asscessing private member outside class { return bno; } char *rbname() { return bname; } char *ran() { return aname; } void accept() { clrscr(); int count=0; fstream f1; 15 | P a g e
  • 16.
    f1.open("CD.dat",ios::in|ios::binary); while(f1.read((char*)this,sizeof(CD))) count++; if(count==0) bno=1; else bno++; f1.close(); cout<<"nEnter The CDNumber:- "<<bno; cout<<"nEnter The CD Title:- "; gets(bname); cout<<"nEnter Singer's Name:- "; gets(aname); cout<<"nEnter The Type of The CD:- "; gets(type); cout<<"nEnter No. of Copies:- "; cin>>nocopy; cout<<"nEnter Year of Release:- "; cin>>yredit; cout<<"nEnter the Cost of CD:- "; cin>>cost; } void accept1() { cout<<"nEnter The CD Title:- "; gets(bname); cout<<"nEnter Singer's Name:- "; gets(aname); cout<<"nEnter The Type of The CD:- "; gets(type); cout<<"nEnter No. of Copies:- "; cin>>nocopy; cout<<"nEnter Year of Release:- "; cin>>yredit; cout<<"nEnter the Cost of The CD:- "; cin>>cost; } void read(); void search(); void searchbname(); void shaname(); void shtype(); 16 | P a g e
  • 17.
    void shcost(); void shrelease(); }; voidwrite() { fstream f1("CD.dat",ios::app|ios::binary); CD e; e.accept(); f1.write((char*)&e,sizeof(e)); cout<<"nRECORD ADDED SUCCESSFULLY!!!!!!!!!!n"; getch(); f1.close(); } void CD::read() { clrscr() ; fstream file ; file.open("CD.dat",ios::in|ios::binary); file.seekg(0) ; int row = 5 , found = 0 , pageno = 1 ; gotoxy(18,1) ; cout<<"LIST OF CDS" ; gotoxy(1,3) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; while (file.read((char *) this, sizeof(CD))) { delay(50) ; found = 1 ; gotoxy(2,row) ; cout<<bno; gotoxy(14,row) ; cout<<bname; gotoxy(27,row) ; cout<<aname; gotoxy(42,row) ; cout<<type; gotoxy(55,row) ; cout<<yredit; gotoxy(66,row) ; cout<<nocopy; gotoxy(74,row) ; 17 | P a g e
  • 18.
    cout<<cost; if ( row== 23 ) { row = 5 ; gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; pageno++ ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; clrscr() ; cout<<"LIST OF CDS" ; gotoxy(1,5) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; } else row++ ; } if ( !found ) { gotoxy(1,5) ; cout<<"Records not found" ; } gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; file.close () ; } void update() { clrscr(); fstream f1("CD.dat",ios::in|ios::out|ios::binary); CD e; int n,flag=0,record=0;; cout<<"nEnter CD No. to be Modifiedn"; cin>>n; while(f1.read((char*)&e,sizeof(e))) { record++; if(e.rbno()==n) 18 | P a g e
  • 19.
    { cout<<"nEnter New Valuesn"; e.accept1(); f1.seekp((record-1)*sizeof(e)); f1.write((char*)&e,sizeof(e)); cout<<"nnnnRecordModified Sucessfullynnn"; getch(); flag=1; break; } } if(!flag) cout<<"nRecord Not Found!!!!!!!n";delay(200); f1.close(); } void del() { clrscr(); fstream f1,f2; f1.open("CD.dat",ios::in|ios::binary); f2.open("temp.dat",ios::out|ios::binary); CD e; int n,flag=0; cout<<"nEnter CD Number to be Deletedn"; cin>>n; while(f1.read((char*)&e,sizeof(e))) { if(e.rbno()!=n) f2.write((char*)&e,sizeof(e)); else flag=1; } if(flag) cout<<"nRecord Deleted!!!!!!!n"; else cout<<"nRecord Not Found!!!!!n";getch(); f1.close(); f2.close(); remove("CD.dat"); rename("temp.dat","CD.dat"); } void CD::search() { 19 | P a g e
  • 20.
    clrscr() ; fstream file; file.open("CD.dat",ios::in|ios::binary); file.seekg(0) ; int n; cout<<"nnEnter the CD number to be searchedn"; cin>>n; clrscr(); int row = 5 , found = 0 , pageno = 1 ; gotoxy(18,1) ; cout<<"LIST OF CDS" ; gotoxy(1,3) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; while (file.read((char *) this, sizeof(CD))) { if(bno==n) { delay(50) ; found = 1 ; gotoxy(2,row) ; cout<<bno; gotoxy(14,row) ; cout<<bname; gotoxy(27,row) ; cout<<aname; gotoxy(42,row) ; cout<<type; gotoxy(55,row) ; cout<<yredit; gotoxy(66,row) ; cout<<nocopy; gotoxy(74,row) ; cout<<cost; if ( row == 23 ) { row = 5 ; gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; pageno++ ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; clrscr() ; 20 | P a g e
  • 21.
    cout<<"LIST OF CDS"; gotoxy(1,5) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; } else row++ ; } } if ( !found ) { gotoxy(1,5) ; cout<<"Records not found" ; } gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; file.close () ; } void CD::searchbname() { clrscr() ; fstream file ; file.open("CD.dat",ios::in|ios::binary); file.seekg(0) ; char n[20]; cout<<"nnEnter the CD name to be searchedn"; gets(n); clrscr(); int row = 5 , found = 0 , pageno = 1 ; gotoxy(18,1) ; cout<<"LIST OF CDS" ; gotoxy(1,3) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; while (file.read((char *) this, sizeof(CD))) { if(strcmpi(bname,n)==0) { delay(50) ; found = 1 ; gotoxy(2,row) ; 21 | P a g e
  • 22.
    cout<<bno; gotoxy(14,row) ; cout<<bname; gotoxy(27,row) ; cout<<aname; gotoxy(42,row); cout<<type; gotoxy(55,row) ; cout<<yredit; gotoxy(66,row) ; cout<<nocopy; gotoxy(74,row) ; cout<<cost; if ( row == 23 ) { row = 5 ; gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; pageno++ ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; clrscr() ; cout<<"LIST OF CDS" ; gotoxy(1,5) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; } else row++ ; } } if ( !found ) { gotoxy(1,5) ; cout<<"Records not found" ; } gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; file.close () ; 22 | P a g e
  • 23.
    } void CD::shaname() { clrscr() ; fstreamfile ; file.open("CD.dat",ios::in|ios::binary); file.seekg(0) ; char n[20]; cout<<"Enter the singer's name whose CDs is to be searchedn"; gets(n); clrscr(); int row = 5 , found = 0 , pageno = 1 ; gotoxy(18,1) ; cout<<"LIST OF CDS" ; gotoxy(1,3) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; while (file.read((char *) this, sizeof(CD))) { if(strcmpi(aname,n)==0) { delay(50) ; found = 1 ; gotoxy(2,row) ; cout<<bno; gotoxy(14,row) ; cout<<bname; gotoxy(27,row) ; cout<<aname; gotoxy(42,row) ; cout<<type; gotoxy(55,row) ; cout<<yredit; gotoxy(66,row) ; cout<<nocopy; gotoxy(74,row) ; cout<<cost; if ( row == 23 ) { row = 5 ; gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; pageno++ ; 23 | P a g e
  • 24.
    gotoxy(1,25) ; cout<<"Press anykey to continue..." ; getch() ; clrscr() ; cout<<"LIST OF CDS" ; gotoxy(1,5) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; } else row++ ; } } if ( !found ) { gotoxy(1,5) ; cout<<"Records not found" ; } gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; file.close () ; } void CD::shtype() { clrscr() ; fstream file ; file.open("CD.dat",ios::in|ios::binary); file.seekg(0) ; char n[20]; cout<<"Enter the Type of CDs to searchedn"; gets(n); clrscr(); int row = 5 , found = 0 , pageno = 1 ; gotoxy(18,1) ; cout<<"LIST OF CDS" ; gotoxy(1,3) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; while (file.read((char *) this, sizeof(CD))) 24 | P a g e
  • 25.
    { if(strcmpi(type,n)==0) { delay(50) ; found =1 ; gotoxy(2,row) ; cout<<bno; gotoxy(14,row) ; cout<<bname; gotoxy(27,row) ; cout<<aname; gotoxy(42,row) ; cout<<type; gotoxy(55,row) ; cout<<yredit; gotoxy(66,row) ; cout<<nocopy; gotoxy(74,row) ; cout<<cost; if ( row == 23 ) { row = 5 ; gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; pageno++ ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; clrscr() ; cout<<"LIST OF CDS" ; gotoxy(1,5) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; } else row++ ; } } if ( !found ) { gotoxy(1,5) ; cout<<"Records not found" ; } gotoxy(66,1) ; 25 | P a g e
  • 26.
    cout<<"Page no. :" <<pageno ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; file.close () ; } void CD::shrelease() { clrscr() ; fstream file ; file.open("CD.dat",ios::in|ios::binary); file.seekg(0) ; char n[20]; cout<<"Enter the Year of Release to be searchedn"; gets(n); clrscr(); int row = 5 , found = 0 , pageno = 1 ; gotoxy(18,1) ; cout<<"LIST OF CDS" ; gotoxy(1,3) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; while (file.read((char *) this, sizeof(CD))) { if(strcmpi(yredit,n)==0) { delay(50) ; found = 1 ; gotoxy(2,row) ; cout<<bno; gotoxy(14,row) ; cout<<bname; gotoxy(27,row) ; cout<<aname; gotoxy(42,row) ; cout<<type; gotoxy(55,row) ; cout<<yredit; gotoxy(66,row) ; cout<<nocopy; gotoxy(74,row) ; cout<<cost; if ( row == 23 ) 26 | P a g e
  • 27.
    { row = 5; gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; pageno++ ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; clrscr() ; cout<<"LIST OF CDS" ; gotoxy(1,5) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; } else row++ ; } } if ( !found ) { gotoxy(1,5) ; cout<<"Records not found" ; } gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; file.close () ; } void CD::shcost() { clrscr() ; fstream file ; file.open("CD.dat",ios::in|ios::binary); file.seekg(0) ; int n; cout<<"Enter the minimum cost to see the CDsn"; cin>>n; clrscr(); int row = 5 , found = 0 , pageno = 1 ; gotoxy(18,1) ; 27 | P a g e
  • 28.
    cout<<"LIST OF CDS"; gotoxy(1,3) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; while (file.read((char *) this, sizeof(CD))) { if(cost>n) { delay(50) ; found = 1 ; gotoxy(2,row) ; cout<<bno; gotoxy(14,row) ; cout<<bname; gotoxy(27,row) ; cout<<aname; gotoxy(42,row) ; cout<<type; gotoxy(55,row) ; cout<<yredit; gotoxy(66,row) ; cout<<nocopy; gotoxy(74,row) ; cout<<cost; if ( row == 23 ) { row = 5 ; gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; pageno++ ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; clrscr() ; cout<<"LIST OF CDS" ; gotoxy(1,5) ; cout<<"nCD No. CD Name Singer's Name Type Release Sale Costnn"; } else row++ ; } } 28 | P a g e
  • 29.
    if ( !found) { gotoxy(1,5) ; cout<<"Records not found" ; } gotoxy(66,1) ; cout<<"Page no. : " <<pageno ; gotoxy(1,25) ; cout<<"Press any key to continue..." ; getch() ; file.close () ; } void backup() { char ch; cout<<"n Are You Sure That You Want To Create A Backup? (y/n)n"; cin>>ch; if(ch=='y') { CD e; fstream f1,f2; f1.open("CD.dat",ios::in|ios::binary); f2.open("susa.dat",ios::out|ios::binary); while(f1.read((char*)&e,sizeof(e))) { f2.write((char*)&e,sizeof(e)); } f1.close(); f2.close(); } cout<<"nnBackup Created!!!!!!";getch(); } void restore() { char ch; cout<<"n Are You Sure You Want to Restore The Last Backup File? (y/n)n"; cin>>ch; if(ch=='y') { 29 | P a g e
  • 30.
    remove("CD.dat"); rename("susa.dat","CD.dat"); cout<<"nnBackup File Restored...."; } else cout<<"nFilenot Restored!!!!nn"; } void menu() { char ch1; CD b; int ch; while(1) { clrscr(); cout<<"nnntt****************************************n"; cout<<"nttt Search Menun"; cout<<"ntt****************************************n"; cout<<"ttt1. Search by CD Numbernttt2. Search by CD Namen" <<"ttt3. Search by Singer Namenttt4. Search by Releasen" <<"ttt5. Search by Typenttt6. Search by Costn" <<"ttt7. Back to Previous Menunttt8. Exitn"; cout<<"ntt****************************************n"; cout<<"nnnttEnter your choice: "; gotoxy(35,22); cin>>ch; switch(ch) { case 1: b.search(); break; case 2: b.searchbname(); break; case 3: b.shaname(); break; case 4: b.shrelease(); break; case 5: b.shtype(); break; 30 | P a g e
  • 31.
    case 6: b.shcost(); break; case 7: mainmenu(); break; case8: exit(0); default: cout<<"nnnInvalid Choicennn"; } } } void mainmenu() { int ch; char ch1; CD b; while(1) { clrscr(); cout<<"nnnnnnnnntt ****************************************nn"; cout<<"tt****** M . A . I . N - M . E . N . U *******n"; cout<<"ntt ****************************************n"; cout<<"nttt1. Add a Recordnttt2. Display All The Recordsn" <<"ttt3. Modify a Recordnttt4. Search a Recordn" <<"ttt5. Delete a Recordnttt6. Create a Backupn" <<"ttt7. Restore the Last Backup Filenttt8. Exitn"; cout<<"ntt ****************************************n"; cout<<"nnntt Enter Your Choice: "; gotoxy(38,29); cin>>ch; switch(ch) { case 1: write(); break; case 2: b.read(); break; case 3: update(); break; 31 | P a g e
  • 32.
    case 4: menu(); break; case 5: del(); break; case6: backup(); break; case 7: restore(); break; case 8: { clrscr(); gotoxy(26,10); delay(200); cout<<"T"; delay(100); cout<<"h"; delay(100); cout<<"a"; delay(100); cout<<"n"; delay(100); cout<<"k"; delay(100); cout<<" Y"; delay(50); cout<<"o"; delay(100); cout<<"u"; delay(100); cout<<" F"; delay(100); cout<<"o"; delay(100); cout<<"r"; delay(100); cout<<" V"; delay(100); cout<<"i"; delay(100); cout<<"s"; delay(100); 32 | P a g e
  • 33.
  • 34.
    clrscr();textcolor(GREEN); char ch1; int ch; charpass[10]; gotoxy(30,15); cout<<"Enter your Password : "; gotoxy(55,15); pass[0]=getch(); cout<<"*"; pass[1]=getch(); cout<<"*"; pass[2]=getch(); cout<<"*"; pass[3]=getch(); cout<<"*"; pass[4]=getch(); cout<<"*"; pass[5]='0'; getch(); CD b; if(strcmpi(pass,"rajat")==0) { clrscr(); cout<<"nnnnnttttWELCOME TO OUR PROJECT nnnnttttCD Management System n MUSIC WORLDn" <<"nnnttt Made by:"; delay(200); cout<<"R"; delay(100); cout<<"A"; delay(100); cout<<"J"; delay(100); cout<<"A"; delay(100); cout<<"T"; delay(100); cout<<" "; delay(50); cout<<"S"; delay(100); cout<<"A"; delay(100); 34 | P a g e
  • 35.
    cout<<"H"; delay(100); cout<<"N"; delay(100); cout<<"I"; gotoxy(25,25); cout<<" Press anyKey to Continuen"; getch(); mainmenu(); } else cout<<"nnnnInvalid Password!!!!!!Try Again.....nnn"; getch(); } 35 | P a g e
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
    43 | Pa g e
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
    References taken fromSumita Arora (Computer Science Class XII and XI) 1. Reeta Sahoo (Computer Science Class XII and XI) 2. Together with Class –XII 3. www.google.com 50 | P a g e