***Please take your time this is a big project*** CSC 2110 Computer Science I Pr
ID: 3704602 • Letter: #
Question
***Please take your time this is a big project***
CSC 2110 Computer Science I Programming Project Due: 04/17/2018 11:00 PM 70 points 10 points extra credit-80 points Submission Format: 1. The project should be submitted using the Blackboard. 2. Include all files in one folder and compress your folder using (zip) not rar. 3. Includes all the following files in one folder: A. The code and the files necessary to compile and test the project. B. Test Plan: Showing how you tested the program (show the steps of your testing procedure along with screen shots). (10 points) C. A short description of the design plan and general comments. (5 points) Final Project: Write a C++ program to manage a library system. The main user is the librarian. Build Specifications (35 points) 1. The system should load a catalog of books, journals, and magazines at the start of the program. (at least five of each) 2. A user can search the catalog: The user of the system can search the library's catalog by using the name of the item. Also, a user can list books by category (Book, Journal, or magazine). If you are looking specifically for a book, you can search by the name of the author 3. A user can check out books, journals, or magazines: The user needs to find the item first, then they can checkit out. A user cannot check out an item that is already checked out. 4. A user can return books, journals, or magazines: A user can return an item. The user needs to find the item first, then they can return it. 5. Add new books, journals, or magazines to the catalog. A librarian can add a new item to the catalogExplanation / Answer
//------------------------ LIBRARY MANAGEMENT PROGRAM IN CPP-------------------------------//
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<iomanip.h>
//--------------------------------------------
class LibraryItem // Library Item include books, journal, magzine, papers
{
char bno[6];
char bname[50];
char aname[20];
public:
void create_LibraryItem()
{
cout<<" NEW LibraryItem ENTRY... ";
cout<<" Enter The LibraryItem no.";
cin>>bno;
cout<<" Enter The Name of The LibraryItem ";
gets(bname);
cout<<" Enter The Author's Name ";
gets(aname);
cout<<" LibraryItem Created..";
}
void show_LibraryItem()
{
cout<<" LibraryItem no. : "<<bno;
cout<<" LibraryItem Name : ";
puts(bname);
cout<<"Author Name : ";
puts(aname);
}
void modify_LibraryItem()
{
cout<<" LibraryItem no. : "<<bno;
cout<<" Modify LibraryItem Name : ";
gets(bname);
cout<<" Modify Author's Name of LibraryItem : ";
gets(aname);
}
char* retbno()
{
return bno;
}
void report()
{cout<<bno<<setw(30)<<bname<<setw(30)<<aname<<endl;}
}; //class ends here
// Stream object global declaration
fstream fp,fp1;
LibraryItem bk;
//------------------------- FILE METHODS TO STORE AND RETRIEVE DATA ------------------------//
//-------------- function to write specific record in file
void write_LibraryItem()
{
char ch;
fp.open("LibraryItem.dat",ios::out|ios::app);
do
{
clrscr();
bk.create_LibraryItem();
fp.write((char*)&bk,sizeof(LibraryItem));
cout<<" Do you want to add more record..(y/n?)";
cin>>ch;
}while(ch=='y'||ch=='Y');
fp.close();
}
//-------------- function to read specific record from file
void display_spb(char n[])
{
cout<<" LibraryItem DETAILS ";
int flag=0;
fp.open("LibraryItem.dat",ios::in);
while(fp.read((char*)&bk,sizeof(LibraryItem)))
{
if(strcmpi(bk.retbno(),n)==0)
{
bk.show_LibraryItem();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<" LibraryItem does not exist";
getch();
}
// -------- function to modify record of file
void modify_LibraryItem()
{
char n[6];
int found=0;
clrscr();
cout<<" MODIFY LibraryItem REOCORD.... ";
cout<<" Enter The LibraryItem no. of The LibraryItem";
cin>>n;
fp.open("LibraryItem.dat",ios::in|ios::out);
while(fp.read((char*)&bk,sizeof(LibraryItem)) && found==0)
{
if(strcmpi(bk.retbno(),n)==0)
{
bk.show_LibraryItem();
cout<<" Enter The New Details of LibraryItem"<<endl;
bk.modify_LibraryItem();
int pos=-1*sizeof(bk);
fp.seekp(pos,ios::cur);
fp.write((char*)&bk,sizeof(LibraryItem));
cout<<" Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<" Record Not Found ";
getch();
}
void delete_LibraryItem()
{
char n[6];
clrscr();
cout<<" DELETE LibraryItem ...";
cout<<" Enter The LibraryItem no. of the LibraryItem You Want To Delete : ";
cin>>n;
fp.open("LibraryItem.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&bk,sizeof(LibraryItem)))
{
if(strcmpi(bk.retbno(),n)!=0)
{
fp2.write((char*)&bk,sizeof(LibraryItem));
}
}
fp2.close();
fp.close();
remove("LibraryItem.dat");
rename("Temp.dat","LibraryItem.dat");
cout<<" Record Deleted ..";
getch();
}
// -------- function to display LibraryItems list
void display_allb()
{
clrscr();
fp.open("LibraryItem.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN ";
getch();
return;
}
cout<<" LibraryItem LIST ";
cout<<"========================================================================= ";
cout<<"LibraryItem Number"<<setw(20)<<"LibraryItem Name"<<setw(25)<<"Author ";
cout<<"========================================================================= ";
while(fp.read((char*)&bk,sizeof(LibraryItem)))
{
bk.report();
}
fp.close();
getch();
}
//----------------- function to issue LibraryItem
void LibraryItem_issue()
{
char sn[6],bn[6];
int found=0,flag=0;
clrscr();
cout<<" LibraryItem ISSUE ...";
cout<<" Enter The student's admission no.";
cin>>sn;
fp.open("student.dat",ios::in|ios::out);
fp1.open("LibraryItem.dat",ios::in|ios::out);
while(fp.read((char*)&st,sizeof(student)) && found==0)
{
if(strcmpi(st.retadmno(),sn)==0)
{
found=1;
if(st.rettoken()==0)
{
cout<<" Enter the LibraryItem no. ";
cin>>bn;
while(fp1.read((char*)&bk,sizeof(LibraryItem))&& flag==0)
{
if(strcmpi(bk.retbno(),bn)==0)
{
bk.show_LibraryItem();
flag=1;
st.addtoken();
st.getstbno(bk.retbno());
int pos=-1*sizeof(st);
fp.seekp(pos,ios::cur);
fp.write((char*)&st,sizeof(student));
cout<<" LibraryItem issued successfully Please Note: Write current date
in backside of LibraryItem and submit within 15 days fine Rs. 1 for each day
after 15 days period";
}
}
if(flag==0)
cout<<"LibraryItem no does not exist";
}
else
cout<<"You have not returned the last LibraryItem ";
}
}
if(found==0)
cout<<"Student record not exist...";
getch();
fp.close();
fp1.close();
}
//----------------- function to deposit LibraryItem
void LibraryItem_deposit()
{
char sn[6],bn[6];
int found=0,flag=0,day,fine;
clrscr();
cout<<" LibraryItem DEPOSIT ...";
cout<<" Enter The student’s admission no.";
cin>>sn;
fp.open("student.dat",ios::in|ios::out);
fp1.open("LibraryItem.dat",ios::in|ios::out);
while(fp.read((char*)&st,sizeof(student)) && found==0)
{
if(strcmpi(st.retadmno(),sn)==0)
{
found=1;
if(st.rettoken()==1)
{
while(fp1.read((char*)&bk,sizeof(LibraryItem))&& flag==0)
{
if(strcmpi(bk.retbno(),st.retstbno())==0)
{
bk.show_LibraryItem();
flag=1;
cout<<" LibraryItem deposited in no. of days";
cin>>day;
if(day>15)
{
fine=(day-15)*1;
cout<<" Fine has to deposited Rs. "<<fine;
}
st.resettoken();
int pos=-1*sizeof(st);
fp.seekp(pos,ios::cur);
fp.write((char*)&st,sizeof(student));
cout<<" LibraryItem deposited successfully";
}
}
if(flag==0)
cout<<"LibraryItem no does not exist";
}
else
cout<<"No LibraryItem is issued..please check!!";
}
}
if(found==0)
cout<<"Student record not exist...";
getch();
fp.close();
fp1.close();
}
//------------------- THE MAIN FUNCTION ----------------
void main()
{
int ch;
do
{
clrscr();
cout<<" MAIN MENU";
cout<<" 1.DISPLAY CATALOG ";
cout<<" 2.SEARCH SPECIFIC ITEM ";
cout<<" 3. CHECKOUT";
cout<<" 4. RETURN";
cout<<" 5. EXIT";
cout<<" Please Enter Your Choice (1-5) ";
cin>>ch;
switch(ch)
{
case 1: display_allb();
break;
case 2: {
char num[6];
clrscr();
cout<<" Please Enter The Item No. ";
cin>>num;
display_spb(num);
break;
}
case 3: {
LibraryItem_issue();
break;
}
case 4:LibraryItem_deposit();
break;
case 5:exit(0);
default :cout<<"";
}
}while(ch!= 5);
}
// --------------------------------------------- END ----------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.