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

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 type

Explanation / 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;
}

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