Create a class named EB_amount. It has the data members units_used and bill. Use member
function to set unit_used. Upto 200 units 3 rupees per unit, 201 to 500, 4 rupees per and above 500
5.5 rupees per unit are allotted by EB. Calculate the bill amount and display the amount. Create
another class Salary with basic, DA and HRA. Set basic by a member function. 104 percent of basic
is assigned as DA and 10 percent is allotted as HRA. Display the total salary. Derive a class Budget
contains income, tuition_fee, house_rent, saving, grocery, eb_bill as data members. Set the values
and get the values of income and eb_bill from parent classes. Display the budget details.
Create a base class called Shape which has two double type values. Use member functions get()
and set() to get and set 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 to display the rectangle or triangle area.
Create a class Matrix to store a m x n matrix. Include necessary constructors and functions to
initialize and display the matrix. Using friend function, find the dot product of two input matrices.
Create a class Date whose object can store a day, month and year. Include the necessary
constructors to initialize the objects and function to display the date in ‘dd/mm/yyyy’ format.
Define a non-member function findAge(Date dob, Date today) which should return the calculated
age from the input dates ‘dob’ and ‘today’. Set this function as friend to Date class. Write a main
function to read the today’s date and date of birth of a person from the user and display the age
of that person by calling the proper 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.
integers = [int(number) for number in input().split()]
K = int(input())
triplets = []
for i in range(len(integers)):
for j in range(i+1,len(integers)):
for k in range(j+1, len(integers)):
tmp = tuple(sorted([integers[i], integers[j], integers[k]]))
if sum(tmp) == K:
if tmp not in triplets:
triplets.append(tmp)
triplets_tuple = tuple(sorted(triplets))
print(*triplets_tuple, sep='\n')
It should also print if there is no triplets matching it should print
Input:
1 5 6 3 5 11
30
Output:
No Matching Triplets Found
Develop a program that uses a function called large_is_zero(). This function takes
two float arguments as pass by reference and then this function sets the large number to zero.
Create a class Rational whose object can store a rational number. (For ex: ¾). Include the necessary constructors to initialize the objects and function to display the rational number in x/y format. Define the following non-member functions.
addRational(Rational r1, Rational r2) : which should return a summation of the two input rational numbers r1 and r2.
mulRational(Rational r1, Rational r2) : which should return the product of the r1 and r2. Set these two functions as friend to the Rational class
Main function to read two rational numbers and display the sum and product of the input by calling the proper functions
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.