DevJourney · code I wrote while learning

README.md

1.3 KB

Single File Programming Question

Problem Statement

Create a class Parent that has a method "add" which prints the addition of two integers.

Create a class child1 that is a child class of the Parent class. It has a method "sub" that prints the subtraction of two integers.

Create a class child2 that is a child class of the Parent class. It has a method "mul" that prints the multiplication of two integers.

Create a class child3 that is a child class of the Parent class. It has a method "div" that prints the division of two integers.

Create an object of the child3 class. Then, from this object, call the four methods add, sub, mul, and div inherited from the child1 class and display the results.

Input format :

The input consists of two space-separated integers: a and b.

Output format :

The first line prints the addition of the given integers.

The second line prints the subtraction of the given integers.

The third line prints the multiplication of the given integers.

The fourth line prints the division of the given integers rounded off to two decimal places.

Code constraints :

-100 ≤ a, b ≤ 103

Sample test cases :

Input 1 :

12 24

Output 1 :

36 -12 288 0.50

Input 2 :

30 -15

Output 2 :

15 45 -450 -2.00