Concept explainers
Redo
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Database Concepts (7th Edition)
Computer Science: An Overview (12th Edition)
C++ How to Program (10th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Can someone help me with this c++ code? Criteria: Program executes without crashing Appropriate Internal Documentation Base Animal Class: Correct Private Data Members Constructors function appropriately (correct number of constructors, number of arguments, output of messages, etc.) Correct get and set functions Derived Dog, Rabbit, Fish, and Snake classes Correct Private Data Members Constructors/destructors function appropriately (correct number of constructors, number of arguments, output of messages, etc.) Correct get and set functions Move function implementation Dynamic allocation of animals Random generation of ages and correct seed value Output contains appropriate information Array used to store 5 animals correctly Memory is deallocated appropriatelyarrow_forwardWrite an OOP program in C++, which contains three, classes i.e. Parent Class, Child1 Class & Child2 Class. Parent Class inherited within Child1 Class & Child2 Class. Parent Class has one member function that is Public: void Show( );. Child1 & Child2 Class will follow the signature of the Parent Class member function; each class will have different function definitions. And during running time a message will be displayed that which class object you want to create to call their member function as shown in the output below. For Example: if enter 1 then it will call parent class function If enter 2 then it will call child1 class function If enter 3 then it will call child2 class function. Hint: Solve this Program using Run Time Polymorphism.arrow_forwardWrite 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_forward
- Write a program that does the following: 1-Define two classes Teacher and Department. Each Teacher has a department object as follow: [3 points] class Department{ int dno; char *name; //add data member to count number of departments automatically public: //add required methods here //define print function that prints all details of department. Note that print function is NOT function member of class Department }; class Teacher{ const int SSN; char *name; Department d; public: //add all required methods //define print function that prints all details of Teacher. Note that print function is NOT function member of class Teacher } 2-inside main do the following: a) create array of 5 Teachers. add all required details for each object inside a loop.(do NOT use cin>>) b)use print function for department and use print function for student. c)define and use a function FindTeachers that takes the array of Teachers and name of department. Then the function returns a list of all Teachers…arrow_forwardI have the basis of a program that works as an inventory, it reads the contents of a file and displays them and their quantity in three places, listed below are the things that I need to add to the program below. Provided is the current code. 1) Convert your structure into a class. For this exercise, you can leave the data as public (otherwise you would have to change the input and output functions). 2) Write a member function show_all that prints all the information for one record - name, cost, markup, and the three inventory numbers. 3) Add a user option S that lets the user see all the information for all the items in the inventory, using the show_all member function. Print a header so the user knows what each column means, and format the output to appear in columns. Hint: do a setwidth() before *each* cout. Pick widths that make sense for name, cost, markup, and the three inventory numbers. Contents of the file: Contents of Inventory.txt Red delicious apples1.00 25 6 8…arrow_forwardWrite a program in the C++ language to create a class Triangle with three member integer variables side1, side2, and side3. Write the parameterized constructor for the class and also add a member function that displays the area of the triangle in the output.arrow_forward
- Write a program in the C++ language to create a class Rectangle with two member integer variables length and breadth. Write the parameterized constructor for the class and also add a member function that displays the area of the rectangle in the output.arrow_forwardWrite the contents of a specification file for a c++ class named ContestResult that contains the following members: An data member winner of type string, initialized to the empty string An data member secondPlace of type string, initialized to the empty string. An data member thirdPlace of type string, initialized to the empty string. A member function called setWinner that has one parameter, whose value it assigns to the data member winner. A member function called setSecondPlace that has one parameter, whose value it assigns to the data member secondPlace. A member function called setThirdPlace that has one parameter, whose value it assigns to the data member thirdPlace. A member function called getWinner that has no parameters and that returns the value of the data member winner. A member function called getSecondPlace that has no parameters and that returns the value of the data member secondPlace. A member function called getThirdPlace that has no parameters and that returns the…arrow_forwardIn c++1. Create a room structure with member-data room dimensions. Write a show () function that displays the room data and an area () function that calculates its face (squaring).In main () create a static array of rooms (Room variables) - the rooms in one apartment. For each of the rooms, display its dimensions and square footage. Determine the total square footage of the apartment.2. Create a Room class with the same member data and member functions:- constructors - by default and with parameters- member-functions set () - to set the corresponding size of the room- member-functions get () - return the corresponding size-show () - outputting a Room object-аrea () - returns the face of the roomIn main (), create:(a) single room objects located in the stack and in dynamic memory, respectively, using all defined constructors(b) 2 arrays of rooms located in the stack and in the dynamic memory (rooms in two apartments), using all defined constructorsFor each of the rooms: set the…arrow_forward
- Question P .Write the implementation (.cpp file) of the Acc2 class of the previous exercise. The full specification of the class is: An data member named sum of type integer. A constructor that accepts no parameters. THe constructor initializes the data member sum to 0. A function named getSum that accepts no parameters and returns an integer. getSum returns the value of sum . Full explain this question and text typing work only We should answer our question within 2 hours takes more time then we will reduce Rating Dont ignore this linearrow_forward3. Write a program in the C++ language to create a class Triangle with three member integer variables side1, side2, and side3. Add the parameterized constructor for the class and also add a member function that displays the area of the triangle in the output.arrow_forwardWrite the following program in C++. 1. 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 theattribute points by a given percentage.6. Include a function called removePoints that is used to reduce a given amount fromthe value of the attribute points. If the resultant value is negative then the value ofthe attribute should be set into zero.7. Include a function called computeGroup that assigns a value to the attribute groupbased on the value of the attribute points as given in the following table. Points Group points < 100 Silver 100 ≤…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr