Question

c++ programming language Instructions In this exercise, you will design the class memberType. Each object of...

c++ programming language

Instructions In this exercise, you will design the class memberType. Each object of memberType 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 memberType—for example, modify, set, and show a person’s name. Similarly, up-date, modify, and show the number of books bought and the amount spent. Add the appropriate constructors. Write the definitions of the member functions of memberType. Write a program to test various operations of your class memberType.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here I am providing the answer for the above question:

Code:

#include <iostream>

using namespace std;

class memberType
{
public:
string personName; //data variables
int memberId;
int numberOfBooksBought;
double amountSpent;
  
memberType(string name,int id,int numberOfBooks,double amount); //parameter constructor
  
void setPersonName(string name); //member functions for personName
void modifyPersonName(string name);
string showPersonName();
  
void setNumberOfBooksBought(int numberOfBooks); //member functions for numberOfBooksBought
void modifyNumberOfBooksBought(int numberOfBooks);
int showNumberOfBooksBought();
  
void setAmoutSpent(double amount); //member functions for amountSpent
void modifyAmountSpent(double amount);
double showAmountSpent();
  
void printDetails(); //a function for printing all the details
};

memberType::memberType(string name,int id,int numberOfBooks,double amount) //constructor definition
{
personName=name;
memberId=id;
numberOfBooksBought=numberOfBooks;
amountSpent=amount;
}

void memberType::setPersonName(string name) //member function definitions
{
personName=name;
}
void memberType::modifyPersonName(string name)
{
personName=name;
}
string memberType::showPersonName()
{
return personName;
}

void memberType::setNumberOfBooksBought(int numberOfBooks)
{
numberOfBooksBought=numberOfBooks;
}
void memberType::modifyNumberOfBooksBought(int numberOfBooks)
{
numberOfBooksBought=numberOfBooks;
}
int memberType::showNumberOfBooksBought()
{
return numberOfBooksBought;
}

void memberType::setAmoutSpent(double amount)
{
amountSpent=amount;
}
void memberType::modifyAmountSpent(double amount)
{
amountSpent=amount;
}
double memberType::showAmountSpent()
{
return amountSpent;
}

void memberType::printDetails()
{
cout<<"Person Name:"<<personName<<"\nId:"<<memberId<<"\nNumber Of Books Bought:"<<numberOfBooksBought<<"\nAmount Spent:"<<amountSpent;
}

int main()
{
memberType person1("abc",101,4,1000); //creating the object of memberType as person1
cout<<"Printing the Details:\n";
person1.printDetails();
  
person1.modifyPersonName("xyz"); //modifying some detials like personname,numberofbooks,amout
person1.modifyNumberOfBooksBought(6);
person1.modifyAmountSpent(1500);
  
cout<<"\n\nModified person name:"<<person1.showPersonName()<<endl; //showing the modified data
cout<<"Modified number of books:"<<person1.showNumberOfBooksBought()<<endl;
cout<<"Modified amount spent:"<<person1.showAmountSpent()<<endl;
  
cout<<"\nPrinting the Details Again:\n";
person1.printDetails();
  
return 0;
}

Screenshot of the Code:


Output:

Hoping that the above answer will help you..Please Comment for further assistance....Thank you...

Add a comment
Know the answer?
Add Answer to:
c++ programming language Instructions In this exercise, you will design the class memberType. Each object of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part...

    Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part 1: In this assignment, you are asked: Stage1:?Design and implement a class named memberType with the following requirements: An object of memberType holds the following information: • Person’s first name (string)?• Person’s last name (string)?• Member identification number (int) • Number of books purchased (int)?• Amount of money spent (double)?The class memberType has member functions that perform operations on objects of memberType. For the...

  • C++ Programing In this exercise, you will design a class memberType. The class has the following...

    C++ Programing In this exercise, you will design a class memberType. The class has the following data members: memberName. A string that holds the name of a person memberID. A string that holds the member identification number numBooks. An int that holds the number of books bought purchaseAmt. A double that holds the amount spent on books In addition, the class should have the following constructor and other member functions. Constructor. The constructor should accept the person’s name and member...

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

  • Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points...

    Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points Design a class named Employee that has the following attributes: * Name ID Number- (Employee's] Identification Number " Department-the name of the department where the employee works " Position-the employee's job title The class should have the following constructors: A constructor that accepts values for all the member data as arguments A constructor that accepts the following values as arguments and assigns them to...

  • Use C++ to create a class called Student, which represents the students of a university. A...

    Use C++ to create a class called Student, which represents the students of a university. A student is defined with the following attributes: id number (int), first name (string), last name (string), date of birth (string), address (string). and telephone (area code (int) and 7-digit telephone number(string). The member functions of the class Student must perform the following operations: Return the id numb Return the first name of the student Modify the first name of the student. . Return the...

  • Using C++, Write a class named Employee that has the following member variables: name. A string...

    Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...

  • Design a class named Employee. The class should keep the following information in

    WRITE IN C++ ONLY PLEASE. IM USING VISUAL STUDIO CODE.1. Employee and ProductionWorker ClassesDesign a class named Employee. The class should keep the following information in• Employee name• Employee number• Hire dateWrite one or more constructors and the appropriate accessor and mutator functions for the class.Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:• Shift (an integer)• Hourly pay rate (a double )The workday...

  • In Java, design and implement the class day that implements the day of the week in...

    In Java, design and implement the class day that implements the day of the week in a program. The class day should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of the type of day: Set the day. Print the day Return the day Return the next day Return the previous day. Calculate and return the day by adding certain days to the current day. For example,...

  • c++ Part 1 Consider using the following Card class as a base class to implement a...

    c++ Part 1 Consider using the following Card class as a base class to implement a hierarchy of related classes: class Card { public: Card(); Card (string n) ; virtual bool is_expired() const; virtual void print () const; private: string name; Card:: Card() name = ""; Card: :Card (string n) { name = n; Card::is_expired() return false; } Write definitions for each of the following derived classes. Derived Class Data IDcard ID number CallingCard Card number, PIN Driverlicense Expiration date...

  • Language is C++ Basic principles and theory of structured programming in C++ by implementing the class:...

    Language is C++ Basic principles and theory of structured programming in C++ by implementing the class: Matrix Use these principles and theory to help build and manipulate instances of the class (objects), call member functions Matrix class implementation from the main function file and, in addition, the Matrix class must have its interface(Matrix.h) in a separate file from its implementation (Matrix.cpp). The code in the following files: matrix.h matrix.cpp matrixDriver.h Please use these file names exactly. Summary Create three files...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT