Define a class Employee with data members as empno, name and designation. Derive a class
Qualification from Employee that has data members UG, PG and experience. Create another class
Salary which is derived from both these classes to display the details of the employee and compute
their increments based on their experience and qualifications.
Create a class called Transmitter. It has three unsigned int private data members: pay_load,
parity and data_packet; It has one function called parity_bit(). It calculates parity bit by XORing
all pay_load bits and assign the value to parity. By using function get pay_load(), pay_load is got.
data_packet is calculated by multiplying parity_bit with 32768 and add the product with (pay_load
– 32768). Create another class called Receiver. It has unsigned int private data members Rx_Pkt
, Rx_Data and E_Flag. Rx_Data is got from Rx_Data as given below. First E_Flag is calculated
from Rx_Pkt by XORing all bits. If E_Flag is zero, then Rx_Data = Rx_Pkt – 32768, Else a
message should warn about corrupted packet. Derive a class called Tranceiver from the above two
classes and check the functionalities. Use any other functions if needed.
Create a class called InputData. It has two private data members data_a and data_b. Set the
values of these two data members by using two public functions get_a() and get_b(). Derive a class
called Arith_Unit from InputData. It contains the functions add(),sub(), mul(),div() to perform
arithmetic operations on data_a and data_b. Derive a class Logic_Unit from InputData. It
contains the functions and(), or() and xor() to perform logical operations on data_a and data_b.
Finally derive a class called ALUnit from Arith_Unit and Logic_Unit classes. It has to perform
arithmetic and logical operations according to the given codes. Choose code 0 to code 6 to perform
the said seven operations. Write sample program to test the ALU class.
Create two classes IntArray to store the set of integer numbers and FloatArray to store decimal
numbers. Add a member function read() for both classes for reading inputs. Create two objects ‘x’
for IntArray and ‘y’ for FloatArray. Read the inputs for x and y. Using a friend function maxmin(x,y),
display the maximum and minimum among the set of integers and decimal numbers.
let's we have a class named Distance having two private data members such as feet(integer),
inches(float), one input function to input values to the data members, one Display function to
show the distance. The distance 5 feet and 6.4 inches should be displayed as 5’- 6.4”. Then
add the two objects of Distance class and then display the result (the + operator should be
overloaded). You should also take care of inches if it's more than 12 then the inches should
be decremented by 12 and feet to be incremented by 1.
Write a program that illustrate the following relationship and co
mment the relationships.
i) const_object.non_const_mem_function
ii) const_object.const_mem_function
iii) non_const_object.non_const_mem_function
iv) non_const_object.const_mem_function
Create a class called Transmitter. It has three unsigned int private data members: pay_load,
parity and data_packet; It has one function called parity_bit(). It calculates parity bit by XORing
all pay_load bits and assign the value to parity. By using function get pay_load(), pay_load is got.
data_packet is calculated by multiplying parity_bit with 32768 and add the product with (pay_load
– 32768). Create another class called Receiver. It has unsigned int private data members Rx_Pkt
, Rx_Data and E_Flag. Rx_Data is got from Rx_Data as given below. First E_Flag is calculated
from Rx_Pkt by XORing all bits. If E_Flag is zero, then Rx_Data = Rx_Pkt – 32768, Else a
message should warn about corrupted packet. Derive a class called Tranceiver from the above two
classes and check the functionalities. Use any other functions if needed.
Write a program having class STRING, With data member which can store character array (Dynamically you can store). It should facility to initialize by parameterize constructor and concatenate STRING objects.
Ex: STRING obj1(“OOP”), obj2 (“IN KIIT”);
Obj1 = obj1 + obj2;
Then obj1 should have “ OOP IN KIIT” string in it.
Question1
Write a C++ program for simple voting system.The program should display ELIGIBLE VOTER when age entered is 18 or more.Else the program should display NOT ELIGIBLE VOTER
QUESTION TWO
As an elder brother/sister write a C++ program for your junior siblings to perform some mathematical operations. The program should receive the first name,age and class of your sibling. The program should welcome him or her with the first name when entered together with a message(example;welcome Richard to basic maths program).
The program should allow him or her to perform area of trapezium when age is above 12 and class is class 5 or above. Else he or she should be allowed to perform perimeter of a rectangle.
Note: All inputs must be entered by the user and not assigned by the programmer.
Create a base class called Shape which has two double type values. Use member function getdata() to get the values. Use a virtual function display_area() to display the area. Derive two specific classes called Triangle and Rectangle from the base class Shape. Redefine display_area() in the derived classes. Write a program that, based on the user's choice, creates a rectangle or triangle object during runtime, points that object with a Shape class pointer, and calls the display_ area() method with that pointer.