DevJourney · code I wrote while learning

README.md

1.1 KB

Single File Programming Question

Problem Statement

Create a program that calculates and prints the areas of two walls. Define a class called Wall with private attributes for length and height. Initialize these variables using a constructor. In the main function, read the dimensions for two walls. Use a member function called calculateArea in the class to calculate the area. Read inputs for two walls and print the result.

Formula:

Area = length * height

Input format :

The first line of input consists of the length and breadth of wall1 separated by space.

The second line of input consists of the length and breadth of wall2 separated by space.

All inputs are double values.

Output format :

The output prints the areas (double) of Wall1 and Wall2 in separate lines, with no specific percisions.

Refer to sample outputs for a better understanding.

Code constraints :

1.0 <= length, breadth <= 100.0

Sample test cases :

Input 1 :

10.5 8.6 8.5 6.3

Output 1 :

Area of Wall 1: 90.3 Area of Wall 2: 53.55

Input 2 :

13.6 12.25 90.10 12.45

Output 2 :

Area of Wall 1: 166.6 Area of Wall 2: 1121.74