Index CPP
Index CPP
20 Define a class named String that represents a string. Overload the operator to
concatenate two String objects.
21 Write a C++ program to manage patient information in a hospital. Impermeant a
class. Patient that stores the patient's name. The class should include :
A constructor to initialize the patient's name
A member function to input patient information.
A member function to display patient details.
22 A hospital wants to create a database for its indoor patients. The information to
store includes:
Patient's name
Date of birth (year, month, and day).
23 Write a C++ program to read city names from a user-specified file and display only
those names that begin with the characters "B" or "C".
24 White a C++ program that takes two objects of the type Complex Number and
returns an object of the same type that represents the sum of the two complex
numbers. The Complex Number class should include:
Constructor to initialize the real and imaginary parts.
An overloaded operator to add two complex numbers
A function to display the complex number.
25 Write a C++ program that converts:
A decimal integer to binary.
An integer or a decimal number to hexadecimal.
26 Create a class called Student to manage student information. The class should
contain data members for the student's roll number, name, and age, implement
exception handling to ensure that if negative values are entered for the roll number
or age, an exception is thrown.
27 You are developing a program to manage complex numbers, where each complex
number is represented by a class. To ensure correct copying of complex numbers,
you need to overload the assignment (=) operator for the Complex class
Write a C++ program to overload the assignment operator (=) to assign one
Complex number object to another.
28 Write a C++ program to evaluate A B 3, where A and B are objects of the same
class, Implement the multiplication operator (*) to multiply a Number object by an
integer, and the assignment operator (=) to assign the result to
another Number object.
29 Write a C++ program to calculate the salary of a medical representative based on
their sales. The bonus and incentives to be offered are based on the total sales. If
sales exceed Rs. 1,50,000, use a specific set of parameters, otherwise, use a
different set. Implement a conditional constructor and destructor to handle the
calculation of salary and bonus.The program divides the medical representative's
salary and bonus calculation into two sets based on the sales amount
Sales Exceeding Rs. 150,000:
Base Salary Rs. 30,000
Bonus 10% of the sales amount
Sales Rs. 150,000 or Less:
Base Salary Rs. 20,000
Bonus: 5% of the sales amount.
30 Write a C++ program to calculate the earnings of a newspaper delivery boy based
on the type of delivery round and the number of rounds done in a week. A delivery
boy earns Rs. 2 for each morning delivery and Rs. 1.50 for each evening delivery.
The boy is paid for either morning or evening deliveries, but not both. Implement a
class with a conditional constructor and destructor to compute and display
the total earnings.
31 You are required to implement a simple application using object-oriented
programming in C++ Define three classes: A, B, and C. The class C is derived
from both A and B. Each class should have a count() member function that is
declared as virtual. Implement the functionality to:
Create objects of type A, B, and C.
Display the current count of objects of each type
Allow the user to interactively create objects and view the counts.
The counts should be maintained such that:
Class A maintains the count of its own objects
Class B maintains the count of its own objects.
Class C maintains the count of its own objects.
32 Write a C++ program that defines a class NameList with a private member to store
an array of ten names.The class should include public member functions to input
ten names from the user, sort these names in descending order, and display them.
In the main function, create an object of the NameList class and use to input the
names, sort them, and then display the sorted names.
33 Write a C++ program that defines a base class Base and several derived classes.
The program should prompt the user to enter a number between 0 and 5.
Depending on the number provided, the program should create an instance of the
corresponding class (either Base or one of the derived classes) and invoke the
show() method of that class using a pointer to the base class.
0: Create an instance of Base
1: Create an instance of Derived 1.
2: Create an instance of Derived2.
3. Create an instance of Derived3.
4: Create an instance of Derived4.
5. Create an instance of Derived5.
34 Write a C++ program that reads input from the user line by line. The input consists
of alternating strings and integers. The program should display the input in two
columns, with strings in the first column and integers in the second column. If
there are more strings than integers, print "EMPTY" in the integer column for the
extra strings, and if there are more integers than strings, print "EMPTY" in the
string column for the extra integers.