In this exercise, you will design a class member Type. Each object of member Typ
ID: 3618641 • Letter: I
Question
In this exercise, you will design a class member Type. Each object of member Type can hold the name of a person, member ID, number of books bought, and amount spent. Include the member functions to perform the various operations on the objects of member type - for example, modify, set, and show a person's name. Similarly, update, modify, and show the number of books bought and the amount spent. Add the appropriate constructors. Write the definitions of the member functions of member type. Write a program to test various operations of your class member typeExplanation / Answer
#include<iostream.h>
#include<conio.h>
class memberType
{
private:
char* name;
int memberID;
int numberofBooksBought;
float amountSpent;
public:
memberType(char*memname)
{
name = memname;
}
voidsetMemberID(int mid)
{
memberID = mid;
}
intgetmemberID()
{
return memberID;
}
voidsetnumberofBooksBought(int numBooks)
{
numberofBooksBought = numBooks;
}
intgetnumberofBooksBought()
{
return numberofBooksBought;
}
voidsetamountSpent(float amount)
{
amountSpent = amount;
}
float getamountSpent()
{
return amountSpent;
}
voiddisplayInfo()
{
clrscr();
cout<<" **************Member Informationdispaly ********************************";
cout<<" Name : "<<name;
cout<<" Member : "<<memberID;
cout<<" No of Books Bought :"<<numberofBooksBought;
cout<<" AmountSpent :"<<amountSpent;
}
};
int main()
{
char* name;
int memID;
int numbooks;
float amount;
cout<<" Please enter the member Name : ";
cin>>name;
cout<<" Please enter the member ID :";
cin>>memID;
cout<<" Please enter the number of books bought :";
cin>>numbooks;
cout<<" Please enter the Amount Spend : ";
cin>>amount;
memberType objMember(name);
objMember.setMemberID(memID);
objMember.setnumberofBooksBought(numbooks);
objMember.setamountSpent(amount);
objMember.displayInfo();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.