Concept explainers
Assume the definition of class houseType as given in Exercise 11. Answer the following questions. (1, 2, 3, 5, 7)
Write the definition of the member function set so that private members are set according to the parameters.
Write the definition of the member function print that prints the values of the data members.
Write the definition of the constructor of the class houseType so that the private member variables are initialized to according to the parameters.
Write a C++ statement that prints the value of the object newHouse.
Write a C + + statement that declares an object house of type newHouse, and initializes the member variables of house to “Ranch”, 3, 2, 2, 2005, 1300, 185000, and 3600.0, respectively.
Which function members are accessors and which are mutators?
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
C++ Programming: From Problem Analysis to Program Design
- SUBJECT: OOPPROGRAMMING LANGUAGE: C++ ALSO ADD SCREENSHOTS OF OUTPUT. Write a class Distance to measure distance in meters and kilometers. The class should have appropriate constructors for initializing members to 0 as well as user provided values. The class should have display function to display the data members on screen. Write another class Time to measure time in hours and minutes. The class should have appropriate constructors for initializing members to 0 as well as user provided values. The class should have display function to display the data members on screen. Write another class which has appropriate functions for taking objects of the Distance class and Time class to store time and distance in a file. Make the data members and functions in your program const where applicablearrow_forwardC++ program: 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. File memberData.txt: 410John Williams0020Lisa Berry235.5030Ron Brown10255.6840Jessey Smith00 The program will be checked by criterias as below: The program can initialize objects of type memberType without error. memberType's isMemberID indicates which member object is assigned the provided ID. memberType's getBooksPurchased returns the number of books purchased. memberType's getTotalAmountSpent returns the total amount…arrow_forwardPlease circle True or False for each of the following statements. C++ A private data member is only accessible through its class’s member functions. TRUE FALSEarrow_forward
- C++ Personal Information Class: Design a class that holds the following personal data: name, age, and phone number. Write appropriate accessor and mutator functions. Demonstrate the class by writing a program that creates three instances of it. One instance should hold your information, and the other two should hold your friend's or family member's information.arrow_forwardPROBLEM COPY CONSTRUCTOR Copy Constructor Ebox team created a course for their employees and wanted to provide the same course for the faculties in one of the colleges. So they decided to replicate the course using a copy constructor. Write a program to display the given details with the normal constructor and the copy constructor. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. The class Course has the following public data members. Data Type string string string string Variable Name course_hame sessionname1 sessionname2 sessionname3 Define a CO the came order 2e e Type here to searcharrow_forwardAll data members must be declared as “private”•No global variable canbe declared and used•Methods within the classand the requested functionscannot have “cin” or “cout” but it should make use of parameters and return value instead.•“cin” and “cout” should be done in main() or any testing functions•Make sure that you clearly show how the C++ class, its methods and all the functions are being called at least twice and print out its return value and its results properly. Define a new “changePassword” function that accepts 3 parameters:o A vector of User object pointerso User ID of the account to be changedo New passwordIt will return true if it can find that User object with the same user ID andchange the password for that User and false otherwise.Show how this function is being called and returning proper information.You can assume that the user ID is unique in the given vector object. Do not use mallocarrow_forward
- Write the following program in C++ Create a class called Employee that includes attributes: empid, name, points,group, and avg with data types: “int”, “String”, “double”, “String”, and “double” respectively.2. Include a constructor with parameters: empid and name.3. Include another constructor to assign default values to the attributes.4. Include a function called addPoints that is used to add a given amount to the valueof the attribute points.5. Include a function called upgradePoints that is used to increase the value of the attribute points by a given percentage.6. Include a function called removePoints that is used to reduce a given amount from the value of the attribute points. If the resultant value is negative then the value of the attribute should be set into zero.7. Include a function called computeGroup that assigns a value to the attribute group based on the value of the attribute points as given in the following table. Points Group points < 100 Silver 100 ≤ points…arrow_forwardProblem Write a C++ program that declares a class named Point to model a point. A point is represented by its coordinates x and y. Separate the class definition from declaration within the same file. Do the following tasks to accomplish the program. 1. Define several constructors for the class as follows. Use constructor initializer and default arguments whenever possible. a. A constructor that accepts two parameters to initialize the coordinates x and y respectively. b. A copy constructor that accepts another Point object. Use a constructor initializer to invoke constructor (a) c. A default constructor that sets the coordinates x and y to 0. Use a constructor initializer to invoke any of the above constructor s. 2. Define a constant method named print() that prints the coordinates x and y of the point. Explain what is a constant method and what is used for? Why is this method better to be declared as a constant method? Write your answers as comments in the program. 3. Define a method…arrow_forwardLab02-03. Reference Type C++ : Write a program that defines an object of type double called myDouble. Define an object of reference type called myReference and initialize it with myDouble. Change the value of myReference. Print the object value using both the reference and the original variable. Change the value of myDouble. Print the value of both objects.arrow_forward
- There is access to private members of a class by any function defined outside the class. true or false c++arrow_forwardProblem description: in C++ (Malik,2017) Programming Exersices Problem 16, pág. 740, Cap 10 Write the definition of a class, swimmingPool, to implement the properties of a swimming pool. Your class should have the instance variables to store the length (in feet), width (in feet), depth (in feet), the rate (in gallons per minute) at which the water is filling the pool, and the rate (in gallons per minute) at which the water is draining from the pool. Add appropriate constructors to initialize the instance variables. Also add member functions to do the following: determine the amount of water needed to fill an empty or partially filled pool, determine the time needed to completely or partially fill or empty the pool, and add or drain water for a specific amount of time. Changes to do. Design a class, where its attributes are pointers Implement the copy constructor member function. Implement the waterfall effect, when entering the information. Use the this pointer to access the…arrow_forwardImportant requirements for all questions: • All data members must be declared as “private” • No global variable is allowed to be declared and used • Methods within the class and the requested functions cannot have “cin” or “cout” but it should make use of parameters and return value instead. • “cin” and “cout” should be done in main() or any testing functions • Make sure that you clearly show how the C++ class, its methods and all the functions are being called at least twice and print out its return value and its results properly.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education