Concept explainers
Solution to
Give the definition of a class named Doctor whose objects are records for aclinic’s doctors. This class will be a derived class of the class SalariedEmployee given in Display 15.5. A Doctor record has the doctor’s specialty (such as “Pediatrician,” “Obstetrician,” “General Practitioner,” etc., so use type string) and office visit fee (use type double). Be sure your class has a reasonable complement of constructors, accessor, and mutator member functions, an overloaded assignment operator, and a copy constructor. Write a driver program to test all your functions.
Want to see the full answer?
Check out a sample textbook solutionChapter 15 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Programming in C
Starting Out with C++: Early Objects
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting out with Visual C# (4th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Starting Out With Visual Basic (8th Edition)
- Problem C • -3: method consonants() had more than one loop • -3: method initials () had more than one loop • -3: at least one method used nested loopsarrow_forwardCreate a class called Bill that a hardware store might use to represent a bill for an item sold at the store. A Bill should include three data members—a part number (type string), a quantity of the item being purchased (type int) and a price per item (type double). Your class should have a constructor that initializes the three data members. Provide a set and a get function for each data member. In addition, provide a member function named getBillAmount that calculates the bill amount (i.e., multiplies the quantity by the price per item), then returns the amount as an int value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to 0. Write a C++ test program that demonstrates class Bill’s capabilities.arrow_forwardThe operator that is required to access members of classes and structs is called: a. Colon operator b. Scope resolution operator c. Operator overloading d. Member access operator e. None of the answers Answer: What is the name of the program that uses and interacts with the class? Answer: By assuming that all libraries are included, replace MYFUNCTION with the proper function name to make the code correct: 001010 111101101 01010101111110 1010101010101 111010101010 0101100 vector> MyVector; int rows= 10, cols = 4; MyVector.MYFUNCTION(rows, vector(cols, 100)); cout << MyVector [0] [1] << endl; for (int i } = 0; i < MyVector.size(); i++) { for (int j 0; j < MyVector[i].size(); j++) cout << MyVector[i][j] << " "; cout << endl;arrow_forward
- In C++, create a class student with member int ID and string name, and a default constructor that prints "Object created". Inside main create an object of student class.arrow_forwardhelp me javaarrow_forward1- Create a hierarchy of Java classes as follows: MyRectangle is_a MyShape; MyOval is a MyShape. Class MyPoint: Class MyPoint is used by class MyShape to define the reference point, p(x, y), of the Java display coordinate system, as well as by all subclasses in the class hierarchy to define the points stipulated in the subclass definition. The class utilizes a color of enum reference type MyColor, and includes appropriate class constructors and methods. The class also includes draw and toString methods, as well as methods that perform point related operations, including but not limited to, shift of point position, distance to the origin and to another point, angle [in degrees] with the x-axis of the line extending from this point to another point. Enum MyColor: Enum MyColor is used by class MyShape and all subclasses in the class hierarchy to define the colors of the shapes. The enum reference type defines a set of constant colors by their red, green, blue, and opacity, components,…arrow_forward
- in c++ Define another new class named “Item” that must inherit from the given Name class. This Item class will manage the following info: name (string) and price (double). It must prevent the creation of an Item object with either an empty or all-blank name. This class must at least complete the methods defined in the Name class: toString method returns a string representation of the Item object in the format of “ITEM( <name> ) PRICE($ <price> ) such as ITEM(eraser) PRICE($1.05) contains method that accepts a search string and returns true if only the name of the item contains the search string as a substring. It returns false otherwise. isTheSame method that compares two Item objects and returns true only if both Item objects have the exact same name (regardless of the price) and false otherwise. Please note that if the given object in the parameter is not an Item object, it will return false.arrow_forwardIN C++ Lab #6: Shapes Create a class named Point. private attributes x and y of integer type. Create a class named Shape. private attributes: Point points[6] int howManyPoints; Create a Main Menu: Add a Triangle shape Add a Rectangle shape Add a Pentagon shape Add a Hexagon shape Exit All class functions should be well defined in the scope of this lab. Use operator overloading for the array in Shape class. Once you ask the points of any shape it will display in the terminal the points added.arrow_forwardUser-defined Class: You will design and implement your own data class. The class will store data that has been read as user input from the keyboard (see Getting Input below), and provide necessary operations. As the data stored relates to monetary change, the class should be named MoneyChange. The class requires at least 2 instance variables for the name of a person and the coin change amount to be given to that person. You may also wish to use 6 instance variables to represent amounts for each of the 6 coin denominations (see Client Class below). There should be no need for more than these instance variables. However, if you wish to use more instance variables, you must provide a legitimate justification for their usage in the internal and external documentation.Your class will need to have at least a default constructor, and a constructor with two parameters:one parameter being a name and the other a coin amount. Your class should also provide appropriate get and set methods for…arrow_forward
- The base class Pet has attributes name and age. The derived class Dog inherits attributes from the base class Pet class and includes a breed attribute. Complete the program to: Create a generic pet, and print the pet's information using print_info(). Create a Dog pet, use print_info() to print the dog's information, and add a statement to print the dog's breed attribute. Ex: If the input is: Dobby 2 Kreacher 3 German Schnauzer the output is: Pet Information: Name: Dobby Age: 2 Pet Information: Name: Kreacher Age: 3 Breed: German Schnauzer Here is the original code: class Pet:def __init__(self):self.name = ''self.age = 0 def print_info(self):print('Pet Information:')print(' Name:', self.name)print(' Age:', self.age) class Dog(Pet):def __init__(self):Pet.__init__(self)self.breed = '' my_pet = Pet()my_dog = Dog() pet_name = input()pet_age = int(input())dog_name = input()dog_age = int(input())dog_breed = input() # TODO: Create generic pet (using pet_name, pet_age) and then call…arrow_forwardIn C++, Create a class called Date that includes three data members: amonth(type int), a day(type int), and a year(type int). The Date class willhave a constructor with three parameters to initialize the three data members.You may assume the values provided for the year and day are correct, but makesure that the month value is in the range 1-12; if it isn't, set the month to1. Provide set and get functions for each data member. Provide a memberfunction displayDate that displays the date in format MM/DD/YYYY.Write a test program that prompts the user to input the month, the day,and the year and uses your Date class to output the formatted date.arrow_forwardPROGRAMMING LANGUAGE: C++ Write a program that has a base class named FlightCrew. This class shouldhave three data members: an integer to store the ID of the crew member, aninteger to store the number of years of service and another integer to storethe total salary of the member. Provide a parameterized constructor in theclass to set the values of the data members.Derive a class Pilot from FlightCrew to contain two additional data members,an integer to store the number of hours of flight and a boolean to storewhether the Pilot has military experience or not. Provide a paramete rizedconstructor in the Pilot class. Provide a function bonus() in the class wherethe bonus of a pilot is his number of flight hours times the 10% of his salary.Likewise, provide a function isEligible() in the class to find out if the pilot iseligible for promotion or not. A pilot is eligible for promotion to the nextrank if he has at least 5 years of experience and the number of total flighthours is greater…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,