I need assistance creating a C code I need you to help me cr

I need assistance creating a C++ code. I need you to help me create the input and output functions that will allow a user to enter a title of a book and the author with spaces in which you\'ll need to use the getline function for these. After you create these classes I need you to go to my library class. The library class allows:

1) The input of an additional book to be entered into the sytem.

2) Listing the current books in the order of which they are currently stored.

3) Outputs the number of books in the library.

4) Outputs the total number of pages in the library.

5) Sorts the books in the library by copyright date and outputting them to the screen. (Ascending order)

6) Sorts the books in the library by title and outputting them to the screen. (Ascending order)

7) Search for a particular book by title and outputting the information on that book (author, date, pages)

8) Search for a particular author and outputting all the books by that author and their information (title, date, pages)

9) Removal of a book.

The self.txt is a backup file for the library and will need a load and save function in which the system will be able to load all current information from as well as saving new information to. For example if there is a new book added in, it will be saved to the shelf.txt file. Please do not change the code inside the main.cc unless something does not work!!! Below is the code that I have so far:

main.cc

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

#include <iostream>
#include <string>
#include <fstream>
#include \"book.h\"
#include \"library.h\"

int menu();
using namespace std;
int main(){
Library mybooks;
Book tmp;
string tmpstring;
int choice;
ifstream ifs;
ofstream ofs;
ifs.open(\"shelf.txt\");

if(!ifs.fail()){
   mybooks.load(ifs);
   ifs.close();
}
// start the user interaction menu
do{
   choice = menu();
   switch(choice){  
   case 1:
       cin>>tmp;
       mybooks.addbook(tmp);
       break;
   case 2:
       mybooks.showall(cout);
       break;
   case 3:
       cout<<\"Currently there are \";
       cout<<mybooks.size();
       cout<<\" books in your library.\ \";
       break;
   case 4:
       cout<<\"There are \"<<mybooks.numpages();
       cout<<\" total pages in your library.\ \";
       break;
   case 5:
       mybooks.sort_by_date();
       break;
   case 6:
       mybooks.sort_by_title();
       break;
   case 7:
       cout<<\"Enter the title of the book:\ \";
       if(cin.peek() == \'\ \')
       cin.ignore();
       getline(cin,tmpstring);
       mybooks.find_title(tmpstring);
       break;
   case 8:
       cout<<\"Enter the author\'s full name:\ \";
       if(cin.peek() == \'\ \')
       cin.ignore();
       getline(cin,tmpstring);
       mybooks.find_author(tmpstring);
       break;
   case 9:
       cout<<\"Enter title to remove:\ \";
       if(cin.peek() == \'\ \')
cin.ignore();
getline(cin,tmpstring);
       mybooks.remove(tmpstring);
   case 0:
       cout<<\"Leaving your library now.\ \";
       break;
   default:
       cout<<\"Not a valid option.\ \";
       break;
   } // bottom of the switch
}while(choice != 0);
// Now saving the library
ofs.open(\"shelf.txt\");
mybooks.save(ofs);
ofs.close();

return 0;
}

// The menu function which returns the user\'s choice
int menu() {
int choice;
cout<<\"Please chose from the following options:\ \";
cout<<\"1) Add a book to the library\ \";
cout<<\"2) See all your books\ \";
cout<<\"3) See how many books are in your library \ \";
cout<<\"4) See total number of pages in your library \ \";
cout<<\"5) Sort books by copyright date \ \";
cout<<\"6) Sort books by title \ \";
cout<<\"7) Find information about a book \ \";
cout<<\"8) See all books by a particular author \ \";
cout<<\"9) Remove a book by entering its title \ \";
cout<<\"0) Quit \ \";

cin>>choice;
return choice;
}

library.cc

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

#include <iostream>
#include \"book.h\"
using namespace std;

#ifndef LIBRARY_H
#define LIBRARY_H

class Library
{
private:
   int numBooks;
   Book numBookss[500];
public:
   Library();
   Library(int numBooks);
   void addbook()
   {
   //add a new book to the library
   };
void showall()
   {
   //show all current books in the library
   };
void size()
{
//Output the current number of books in the library
};
void numpages()
{
//Output number of pages in the library
};
void sort_by_date
{
//Sort all the books by copyright date. Ascending order
};
void sort_by_title
{
//Sort all the books by title. Ascending order
};
void find_title
{
//Search the library by title and output the information of that book
};
void find_author
{
//Search the library by author and ouput the information for all books written by that author
};
void remove
{
//remove a book from the library
};
void save
{
//Saves the data in the library in the backup file \"shelf.txt\"
};
};
#endif

book.cc

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

#include <iostream>
#include \"book.h\"
#include <string>
using namespace std;
class Book{
private:
std::string title;
   std::string author;
   int year;
   int pages;
public:
Book(){

}
void input(std::istream& ins){

}
void output(std::ostream& outs)const{

}
string get_title()const{

}
string get_author()const{

}
int get_copyright()const{

}
int get_pages()const{

}
};

shelf.txt

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

The Hobbit
Tolkien, JRR
1937
350
Catcher in the Rye
Salinger, JD
1951
175
Dune
Herbert, Frank
1965
420

Please let me know if you have any questions. Thank you

Solution

code for display books and delete books:

#include <iostream>
#include <string>
#include <fstream>
#include \"book.h\"
#include \"library.h\"
int menu();
using namespace std;
int main(){
Library mybooks;
Book tmp;
string tmpstring;
int choice;
ifstream ifs;
ofstream ofs;
ifs.open(\"shelf.txt\");

if(!ifs.fail()){
mybooks.load(ifs);
ifs.close();
}
// start the user interaction menu
do{
choice = menu();
switch(choice){
case 1:
cin>>tmp;
mybooks.addbook(tmp);
break;
case 2:
mybooks.showall(cout);
break;
case 3:
cout<<\"Currently there are \";
cout<<mybooks.size();
cout<<\" books in your library.\ \";
break;
case 4:
cout<<\"There are \"<<mybooks.numpages();
cout<<\" total pages in your library.\ \";
break;
case 5:
mybooks.sort_by_date();
break;
case 6:
mybooks.sort_by_title();
break;
case 7:
cout<<\"Enter the title of the book:\ \";
if(cin.peek() == \'\ \')
cin.ignore();
getline(cin,tmpstring);
mybooks.find_title(tmpstring);
break;
case 8:
cout<<\"Enter the author\'s full name:\ \";
if(cin.peek() == \'\ \')
cin.ignore();
getline(cin,tmpstring);
mybooks.find_author(tmpstring);
break;
case 9:
cout<<\"Enter title to remove:\ \";
if(cin.peek() == \'\ \')
cin.ignore();
getline(cin,tmpstring);
mybooks.remove(tmpstring);
case 0:
cout<<\"Leaving your library now.\ \";
break;
default:
cout<<\"Not a valid option.\ \";
break;
} // bottom of the switch
}while(choice != 0);
// Now saving the library
ofs.open(\"shelf.txt\");
mybooks.save(ofs);
ofs.close();
return 0;
}
// The menu function which returns the user\'s choice
int menu() {
int choice;
cout<<\"Please chose from the following options:\ \";
cout<<\"1) Add a book to the library\ \";
cout<<\"2) See all your books\ \";
cout<<\"3) See how many books are in your library \ \";
cout<<\"4) See total number of pages in your library \ \";
cout<<\"5) Sort books by copyright date \ \";
cout<<\"6) Sort books by title \ \";
cout<<\"7) Find information about a book \ \";
cout<<\"8) See all books by a particular author \ \";
cout<<\"9) Remove a book by entering its title \ \";
cout<<\"0) Quit \ \";
cin>>choice;
return choice;
}
library.cc
----------------------------------------------------------------------
#include <iostream>
#include \"book.h\"
using namespace std;
#ifndef LIBRARY_H
#define LIBRARY_H
class Library
{
private:
int numBooks;
Book numBookss[500];
public:
Library();
Library(int numBooks);
void addbook()
{
//add a new book to the library
};
void showall()
{
fstream f, f1;
clrscr();
f.open(\"book.dat\", ios::in);
if(!f){
cout<<\"ERROR!!! FILE COULD NOT BE OPEN \";
getch();
return;
}
cout<<\"\ \ \\t\\tBook LIST\ \ \";
cout<<\".....................................................\ \";
cout<<\"Book Number\"<<setw(20)<<\"Book Name\"<<setw(25)<<\"Author\ \";
cout<<\".......................................................\ \";
while(f.read((char*)&b, sizeof(book))) b.report();
f.close();
getch();
}
};
void size()
{
//Output the current number of books in the library
};
void numpages()
{
//Output number of pages in the library
};
void sort_by_date
{
//Sort all the books by copyright date. Ascending order
};
void sort_by_title
{
//Sort all the books by title. Ascending order
};
void find_title
{
//Search the library by title and output the information of that book
};
void find_author
{
//Search the library by author and ouput the information for all books written by that author
};
void remove
{
clrscr();
cout<<\" DELETE BOOK ...\";
cout<<\"\ \ Enter Book number to Delete : \";
cin >> n;
f.open(\"book.dat\", ios::in|ios::out);
fstream f2;
f2.open(\"Temp.dat\", ios::out);
f.seekg(0, ios::beg);
while( f.read((char*)&b, sizeof(book)) ) if(strcmpi(b.retbno(),n)!=0) f2.write((char*)&b, sizeof(book));
f2.close();
f.close();
remove(\"book.dat\");
rename(\"Temp.dat\",\"book.dat\");
cout<<\"\ \ \\tRecord Deleted ..\";
getch();
}
     
void save
{
//Saves the data in the library in the backup file \"shelf.txt\"
};
};
#endif
book.cc
-----------------------------------------------------------------
#include <iostream>
#include \"book.h\"
#include <string>
using namespace std;
class Book{
private:
std::string title;
std::string author;
int year;
int pages;
public:
Book(){
}
void input(std::istream& ins){
}
void output(std::ostream& outs)const{
}
string get_title()const{
}
string get_author()const{
}
int get_copyright()const{
}
int get_pages()const{
}
};
shelf.txt
-----------------------------------------------------------------------
The Hobbit
Tolkien, JRR
1937
350
Catcher in the Rye
Salinger, JD
1951
175
Dune
Herbert, Frank
1965
420
Please let me know if you have any questions. Thank you

I need assistance creating a C++ code. I need you to help me create the input and output functions that will allow a user to enter a title of a book and the aut
I need assistance creating a C++ code. I need you to help me create the input and output functions that will allow a user to enter a title of a book and the aut
I need assistance creating a C++ code. I need you to help me create the input and output functions that will allow a user to enter a title of a book and the aut
I need assistance creating a C++ code. I need you to help me create the input and output functions that will allow a user to enter a title of a book and the aut
I need assistance creating a C++ code. I need you to help me create the input and output functions that will allow a user to enter a title of a book and the aut
I need assistance creating a C++ code. I need you to help me create the input and output functions that will allow a user to enter a title of a book and the aut
I need assistance creating a C++ code. I need you to help me create the input and output functions that will allow a user to enter a title of a book and the aut
I need assistance creating a C++ code. I need you to help me create the input and output functions that will allow a user to enter a title of a book and the aut

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site