Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Programming Language. Learn how to create a class that can be aggregated to

ID: 3837974 • Letter: C

Question

C++ Programming Language.

Learn how to create a class that can be aggregated to another class.

Create an object that accesses methods in another class.

Pass data to, and retrieve data from, aggregated objects created through composition.

Instructions:

Read the problem,

Create a program that collects book titles for a book seller. Prompt the user for the title of the book, the author, the publisher and the ISBN number. The ISBN number must 13 digits. After data is entered the program should display the title, author, publisher and ISBN.

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

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

#1) The main() function should do nothing but create an object of the primary class type and call it's methods.

ISBN should be in an aggregate class.

#2) Write code that solves the problem described in #1.

Pause the program so that the console does not disappear until a key is pressed.

Insure that you properly document your code.

Assignment Composition

Create a project that uses am aggregate class. Purpose

Learn how to create a class that can be aggregated to another class.

Create an object that accesses methods in another class.

Pass data to, and retrieve data from, aggregated objects created through composition.

Explanation / Answer

// Example program
#include <iostream>
#include <string>
using namespace std;

class Agg
{
public:
long isbn;
void disp(long ll) // Aggregate class for ISBN
{
cout<<"ISBN "<<ll;
}
};
class Prinp
{
public:
long l,d; //variable declaration
string bname,aname,pname;
int r,c;
void input() //taking input from user
{
do
{
cout<<"Enter the title of the book ";
cin>>bname;
cout<<"Enter the author of the book ";
cin>>aname;
cout<<"Enter the publisher name of the book ";
cin>>pname;
cout<<"Enter the ISBN no ";
cin>>l;
d=l;
while(l!=0) //calculating the digits of ISBN
{
r=l%10;
c=c+1;
l=l/10;
}
}while(c!=13);
cout<<"Name of the book "<<bname<<" "; //Displaying the result
cout<<"Name of the author "<<aname<<" ";
cout<<"Name of the publisher "<<pname<<" ";
Agg a;
a.disp(d);
}
};

  
int main()
{
Prinp obj; //object of the class
obj.input();
system("pause"); //console is paused until a key is pressed.
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote