Here is the solution if you have any doubts then you can write in the comment section.
Please give feedback.
Solution:
//header file
#include <bits/stdc++.h>
using namespace std;
//class book
class book
{
//private variables
private:
char title[64];
char author[64];
int pages;
public:
//constructor
book(char* Title,char* Author,int Pages)
{
//assigning values to corresponding variables
strcpy(title,Title);
strcpy(author,Author);
pages=Pages;
}
//show_book() function to print the data
void show_book()
{
cout<<"*********************************************\n";
cout<<"Title: "<<title<<"\n";
cout<<"Author: "<<author<<"\n";
cout<<"Pages: "<<pages<<"\n";
}
};
//class libraryCard inherits book
class libraryCard:public book
{
//private variables
private:
char catalog[64];
int checked_out;
public:
//constructor, which also call constructor of parent class(book class)
libraryCard(char* Title,char* Author,int Pages,char* Catalog,
int Checked_out):book(Title,Author,Pages)
{
//assigning values to variables
strcpy(catalog,Catalog);
checked_out=Checked_out;
}
//show_card() function to print data
void show_card()
{
//call show_book() function to print values of parent class
show_book();
cout<<"Catalog: "<<catalog<<"\n";
//condition for checked_out
if(checked_out==1)
cout<<"Status: Checked out\n";
else
cout<<"Status: Available\n";
cout<<"*********************************************\n";
}
};
int main()
{
//local variables
char title[64];
char author[64];
int pages;
char catalog[64];
int checked_out;
//enter data from user
cout<<"Enter Title: ";
cin.getline(title,64);
cout<<"Enter Author: ";
cin.getline(author,64);
cout<<"Enter Pages: ";
cin>>pages;
/*this statement is to ignore new line after an integer input, if we didn't
write this then catalog will store newline*/
cin.ignore();
cout<<"Enter Catalog: ";
cin.getline(catalog,64);
cout<<"Enter Checked_out: ";
cin>>checked_out;
//create object of libraryCard class
libraryCard lc(title,author,pages,catalog,checked_out);
cout<<"\n\n";
//call function show_card()
lc.show_card();
return 0;
}
Output:

Thank You!
C++ program Suppose we have the following book base class: class book { public: book(char *,...
Suppose we have the following book base class: class book { public: book(char *, char *, int); void show_book(); private: char title[64]; char author[64]; int pages; }; Suppose that we need to derive a new class, called libraryCard class, which adds the following members to the book class: char catalog[64]; int checked out; // 1 if checked out, otherwise 0 if available libraryCard(char *, char *, int, char *, int); void show_card(); 1. Derive the new class from the base...
Please use C++
Suppose we have the following book base class: class book { public: book(char*, char *, int); void show_book(); private: char title[64]; char author[64]; int pages; }; Suppose that we need to derive a new class, called libraryCard class, which adds the following members to the book class: char catalog[64]; int checked_out; // 1 if checked out, otherwise 0 if available libraryCard(char*, char *, int, char *, int); void show_card(); 1. Derive the new class from the base...
You are going to model a Book in a library. The Book class should contain a title and an author (exactly 1 author is OK). Also, a book can be checked out and returned by a student. A Book object should be able to identify the student who currently holds the book. 1.Design the public interface (public constructor and public methods) for a class Book. You can use String to represent title, author, and student. 2. Implement the class Book...
Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable<Book> in the class definition. Now, all book objects are instances of the java.lang.Comparable interface. Write a test program that creates an array of ten books. 1. Use Arrays.sort( Book[]l books) from the java.util package to sort the array. The order of objects in the array is determined using compareTo...) method. 2. Write a method that returns the most expensive book in the...
C++
In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Туре String String String Attribute title author ISBN Textbook* next Library class should have a head node as an attribute to keep the list of the books. Also, following member...
please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...
Create a base class named Book. Data fields include title and author; functions include those that can set and display the fields. Derive two classes from the Book class: Fiction, which also contains a numeric grade reading level, and NonFiction, which contains a variable to hold the number of pages. The functions that set and display data field values for the subclasses should call the appropriate parent class functions to set and display the common fields, and include specific code...
2016 points output of following Java Program? public class Base { public final void show() { . System.out.println("Base::show() called"); public class Derived extends Base { public void show() { System.out.println("Derived::show() called"); } e lor rested in order public class Main { ects from and public static void main(String[] args) { Base b = new Derived(); b.show();
10.15 LAB: Book information (overriding member methods)Given main() and a base Book class, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define a printInfo() method that overrides the Book class' printInfo() method by printing not only the title, author, publisher, and publication date, but also the edition and number of volumes.Ex. If the input is:The Hobbit J. R. R. Tolkien George Allen & Unwin 21 September 1937 The Illustrated Encyclopedia of the Universe James W. Guthrie Watson-Guptill 2001 2nd 1the output is:Book Information: Book Title: The Hobbit Author: J. R. R. Tolkien Publisher: George Allen & Unwin Publication Date: 21 September 1937 Book Information: Book Title: The Illustrated Encyclopedia of the Universe Author: James W. Guthrie Publisher: Watson-Guptill Publication Date: 2001 Edition: 2nd Number of Volumes: 1Note: Indentations use 3 spaces.BookInformation.javaimport java.util.Scanner; public class BookInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Book myBook = new Book();...