C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

The binary tree of Figure 11-35 is to be used for Exercises 9 through 13.

13. Delete nodes 80 and 58 in that order. Redraw the binary tree after each deletion.

15. The nodes in a binary tree in preorder and inorder sequences are as follows: preorder: ABCDEFGHIJKLM inorder: CEDFBAHJIKGML Draw the binary tree


Build a patient base class consisting of

Attributes: full name (string), hometown (string), year of birth (int)

Functions: Create, import, and export information

Build a medical record class that inherits public from the patient class, adding:


Attributes: medical record name (string), hospital charge amount (double)

Functions: Create, import, export information, calculate current age.

Write a main program that does:


Enter a list of N medical records

Sort the list by descending age of the patients

Display the list of patients with age <=10

Show information of the patients with the highest hospital fees


Implement the class ComplexNumber, the real and imaginary parts of the complex number can

be int, float or double. Overload operators +,-,*,~

Generalize this class into template, and write appropriate main function to test it.

#include

usingnamespace std;

template

class ComplexNumber

{

public:

void print() const;

/* prints the complex number */

ComplexNumber();

/* constructor */

ComplexNumber(T, T);

/* constructor with parameters */

ComplexNumber operator + (ComplexNumber); /*overload + */

ComplexNumber operator - (ComplexNumber); /*overload - */

ComplexNumber operator * (ComplexNumber); /*overload * */

void operator ~ (); /*overload ~, takes complex conjugate of calling

complexnumber, i.e. a+iba-ib*/

private:

T a; /*real part of complex numeber*/

T b; /* imaginary part of complex numeber */

};


Write a class LocalPhone that contains an attribute phone to store a local telephone number. The class contains member functions to input and display phone number. Write a child class NatPhone for national phone numbers that inherits LocPhone class. It additionally contains an attribute to store city code. It also contains member functions to input and show the city code. Write another class IntPhone for international phone numbers that inherit NatPhone class. It additionally contains an attribute to store country code. It also contains member functions to input and show the country code. Test these classes from main() by creating objects of derived classes and testing functions in a way that clear concept of multi-level Inheritance


Start with the publication, book and tape classes. Add base class sales that holds an array of three floats so that it can record the dollar sales of a particular publication for the last three months. Include a getdata() function to get three sale amount from the user and a putdata() function to display the sales figure. Alter the book and tape classes, so they are derived from both publication and sales. An object of book or tape should input and output and sales data along with other data. Write a main function to create a book and tape object and exercise their input/output capabilities


An organization has two types of employees: regular and adhoc. Regular employees get a salary which is basic + DA + HRA where DA is 10% of basic and HRA is 30% of basic. Adhoc employees are daily wagers who get a salary which is equal to Number * Wage.

Define the constructors. When a regular employee is created, basic must be a parameter. When adhoc employee is created wage must be a parameter. (iii) Define the destructors. (iv)Define the member functions for each class. The member function days ( ) updates number of the Adhoc employee. (v) Write a test program to test the classes


 derive a class hierarchy for the item set given below



Item sets:


Engine , InternalCombustineEngine , ExternalCombustineEngine , PetrolEngine, DieselEngine, SteamEngine | Virtual Function GetEfficiency()



Write c++ program to find efficiency of petrol engine, diesel engine and steam engine.


Suppose you are playing a killing game and have to kill few of your enemies. You are at a cliff



and from there you can see few of them. You see the enemies at your height only. Therefore,



you can only kill at the same height. The enemies are forming a balanced binary tree where



their General is at the top of the other cliff, his two commanders are on the first level below



him. The soldiers are at the lowest level. Total four soldiers are appointed. Under both the



commanders exact two soldiers serve.



You have to make a strategy to kill the left commander first, than whoever takes his position



kill him. Now start killing the right side with same strategy until only one enemy is left at left



side. Now increase your height and kill the General. You can only win if only three of your



enemies are left.



Display the enemies who are left and who have been killed. Don’t forget to print your victory



message.

Create a class GradeBook that maintains the course name as a data member so that it can be used


or modified at any time during a program's execution. The class contains member functions


setCourseName, getCourseName and displayMessage. Member function setCourseName stores a


course name in a GradeBook data member, member function getCourseName obtains a


GradeBook's course name from that data member. Member function displayMessage which now


specifies no parameters but displays a welcome message that includes the course name.


The class should also take input for student name (string) and student marks (float). The


number of students for which grades are to be entered should be specified by the user. The


program should also calculate and print the grades for students.

LATEST TUTORIALS
APPROVED BY CLIENTS