#include
#include
#include
#include
#include
#include
class with_file
{
public:
char name[20];
char w_name[20];
char acc_no[7];
int k,i,l_c_n;
char string[10];
int file_id;
char c;
char dept_name[10];
int count;
int pos;
char choice;
public:
with_file(){ //call of constructor
k=0;
file_id=1;
choice='\0';
}
void sitting();
};
void with_file::sitting(){
cout<<"\t\t..WELCOME TO LIBRARY MANAGEMENT SOFTWARE.."<
cout<<"\n\nWhat type of work do you want"<
cout<<"\t01.Log in as Student."<
cout<<"\t02.Log in as Librarian."<
cout<<"\t03.Back"<
cin>>i;
if(i==1)
{
count=1;
while(count){
clrscr();
cout<<"To borrow book press b"<
cin>>choice;
switch(choice){
case 'b':
clrscr();
cout<<"Enter your library card no.:"<
cin>>l_c_n;
if((l_c_n>1000 && l_c_n<1121) || (l_c_n>3000 && l_c_n<3121)|| (l_c_n>5000 && l_c_n<5121) || (l_c_n>7000 && l_c_n<7061) || (l_c_n>9000 && l_c_n<9061))
{
pos=1;
while(pos){
clrscr();
cout<<"To take book press 1"<
cin>>pos;
if(pos==1){
clrscr();
itoa(l_c_n,string,10);
strcat(string,".txt");
ofstream file(string,ios::ate);
int loop;
cout<<"How many book will you take?(1 to 3)? ";
cin>>loop;
while(loop)
{
cout<<"Name of the book: ";
gets(name);
cout<<"Accession no: ";
gets(acc_no);
int p=0;
file<
while(name[p]){
file<
p++;
}
while(p<20){
file<<'\0';
p++;
}
int q=0;
while(acc_no[q]){
file<
q++;
}
while(q<7){
file<<' ';
q++;
}
loop--;
}
file.close();
}
}
break;
case 'r':
clrscr();
cout<<"Give Department Name: ";
cin>>dept_name;
strcat(dept_name,".txt");
ifstream open_file(dept_name);
if(!open_file){
cout<<"There is no information about this department"<
}
else{
while(!open_file.eof()){
open_file.get(c);
if(c=='\0'){
cout<<" ";
}
else{
cout<
}
}
}
open_file.close();
getch();
break;
case 'e':
count=0;
break;
}
else {cout<<"Sorry!! You are not a valid student.";}
getch();
}
}
}
if(i==2){
int pass;
cout<<"Enter the librarian password:";
cin>>pass;
if(pass==1234)
{
count=1;
while(count){
int i;
clrscr();
cout<<"To insert new book info press i"<
cout<<"To create library card press a"<
cin>>choice;
switch(choice){
case 'i':
clrscr();
pos=1;
while(pos){
clrscr();
cout<<"To give book info press 1"<
cin>>pos;
if(pos==1){
clrscr();
cout<<"Give Department Name: ";
cin>>dept_name;
strcat(dept_name,".txt");
ofstream file(dept_name,ios::ate);
int loop;
cout<<"How many book info will be given? ";
cin>>loop;
while(loop){
cout<<"Name of the book: ";
gets(name);
cout<<"Name of the Author: ";
gets(w_name);
cout<<"Accession no: ";
gets(acc_no);
int i=0;
file<
while(name[i]){
file<
i++;
}
while(i<20){
file<<'\0';
i++;
}
int j=0;
while(w_name[j]){
file<
j++;
}
while(j<20){
file<<'\0';
j++;
}
i=0;
while(acc_no[i]){
file<
i++;
}
while(i<7){
file<<' ';
i++;
}
loop--;
}
file.close();
}
}
break;
case 'r':
clrscr();
cout<<"Give Department Name: ";
cin>>dept_name;
strcat(dept_name,".txt");
ifstream open_file(dept_name);
if(!open_file){
cout<<"There is no information about this department"<
}
else{
while(!open_file.eof()){
open_file.get(c);
if(c=='\0'){
cout<<" ";
}
else{
cout<
}
}
}
open_file.close();
getch();
break;
case 'a':
clrscr();
ofstream fout;
fout.open("card.txt",ios::out) ;
char sname[20],dept[5];
long int roll;
cout<<"Enter ur Full Name:";
gets(sname);
cout<<"\nDepartment name:" ;
gets(dept);
cout<<"\nEnter roll by presing 1:: ";
cin>>roll;
fout<
cout<<"\n\nName Dept. Roll\n\n";
cout<
cout<<"\n\nur library card No:"<
fout.close();
getch();
break;
case 'c':
clrscr();
char file[80];
cout<<"File to delete:";
gets(file);
if (remove(file) == 0)
cout<<"Removed..."<
else
perror("remove");
getch();
break;
case 'e':
count=0;
break;
}
}
}
}
}
void main()
{
clrscr();
int i,j;
with_file ob2;
ob2.sitting();
}
No comments:
Post a Comment