Answer to Question #224820 in C++ for snr

Question #224820

Create a class Book that contains instance variables like BKName, BKId and BKAuthor, a

parameterized constructor to initialize its instance variables, a method BKUpdateDetails(String name,

int id, String author), that accepts new values for name, Id and author as parameters and updates

the corresponding instance variable values of that object and another method BKDisplay() to display

the book details. Create a class BookDemo and provide main method for instantiate a Book object,

display the original book details, update its details with new values, and display the updated book

details


1
Expert's answer
2021-08-10T06:49:16-0400
#include <iostream>
using namespace std;
class Book {
 public:
   string BkName;
   int BkId;
   string BkAuthor;
  /* Book (string x, int y, string z){
   BkName = x;
   BkId = y;
   BkAuthor = z;
   }
   */
   void BKUpdateDetails()
   {
   cout<<"Enter Book Name: "; cin>>BkName;
   cout<<"Enter Book ID: "; cin>>BkId;
   cout<<"Enter Book Author: "; cin>>BkAuthor;
   }
   void BKDisplay()
   {
   cout<<"BookName"<<" "<<"BookId"<<" "<<"BookAuthor"<<endl;
   cout<<BkName<<" "<<BkId<<" "<<BkAuthor<<endl;
   }
};

int main()
{
    class Book b;
    b.BKUpdateDetails();
    b.BKDisplay();
    cin.get();
    return 0;
}

Part 2

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS