include ltiostreamgtinclude ltstringgtusing


#include
#include
using namespace std;
class Book

{
private:
string title;
int iD;
int year_pub;
string author;
public:
string getTitle();
int getId();
int getYear_Pub();
string getAuthor();
void set(string,int,int,string);
};
void Book::set(string title,int iD,int year_pub,string author)
{
this -> title = title;
this -> iD = iD;
this -> year_pub = year_pub;
this -> author = author;
}
string Book ::getTitle()
{
return title;
}
int Book ::getId()
{
return iD;
}
int Book ::getYear_Pub()
{
return year_pub;
}
string Book ::getAuthor()
{
return author;
}
int main()
{

Book A,B,C;
int pick, year;

A.set("C++ Plus Data Structures:5th Edition",101,2013,"Nell Dale");
B.set("Starting out with C++: From Control Structures through Objects",102,1996,"Tony Gaddis");
C.set("C++ How to Program",103,2007,"Paul and Harvey Deitel");

cout<< "Welcome to Book Search"<do
{
cout< cout<<"Enter 1 to see all books."< cout<<"Enter 2 to search a book by the Year."< cout<<"Enter 3 to exit this program."< cout<<"Enter a number: "< cin >> pick;

switch(pick)

{
case 1:
cout< cout<<"There is 3 books here:"< cout<
cout<<"Title:"< cout<<"ID:"< cout<<"Year:"< cout<<"Author:"< cout<
cout<<"Title:"< cout<<"ID:"< cout<<"Year:"< cout<<"Author:"< cout<
cout<<"Title:"< cout<<"ID:"< cout<<"Year:"< cout<<"Author:"< break;
case 2:
cout<<"Please enter the year you would like to search"< cin >>year;
if (year==A.getYear_Pub())

{
cout<<"Title:"< cout<<"ID:"< cout<<"Year:"< cout<<"Author:"< cout< }

else if (year==B.getYear_Pub())
{
cout<<"Title:"< cout<<"ID:"< cout<<"Year:"< cout<<"Author:"< cout< }
else if(year==C.getYear_Pub())
{
cout<<"Title:"< cout<<"ID:"< cout<<"Year:"< cout<<"Author:"< cout< }
else
cout<<"There is no book by that year."<

break;
case 3:
cout<<"End of program."<

break;
default:
cout<<"Not a valid number.\n"
<<"Enter again."< }
}
while(pick !=3);

return 0;

}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: include ltiostreamgtinclude ltstringgtusing
Reference No:- TGS0220691

Expected delivery within 24 Hours