Write a C++ program to calculate the area of the rectangle using the friend function. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Create separate classes in separate files. The class Rectangle has the following private attributes. Data Type int int Variable Name length breadth Include appropriate getters and setters for the above class. Define a function to find the area of a rectangle which will be able to access the private data members of the Rectangle class. Method Description void calcArea(Rectangle rec) This function is used to calculate the area and display it. In the main() method, read the length and breadth details from the user and display the area by calling the function. Input and Output Format: Please refer to the sample input and output for formatting specifications. [All text in bold are input and the remaining are output] Sample Input and Output : Enter the length 10 Enter the breadth 20 Area: 200

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 29SA
icon
Related questions
Question

QUESTION PROVIDED IN ATTACH IMAGE KINDLY SEE. PROVIDE OUTPUT AS IT IS SHOWN IN QUESTION.

 

AND BELOW TEMPLATES PROVIDED CHECK THIS BEFORE MAKING SOLUTION ( main.cpp , rectangle.cpp)

----------------- TEMPLATES BELOW FOR SOLUTION -----------------------

 

main.cpp template

#include<iostream>
#include<stdlib.h>
using namespace std;

int main()
{

//Fill your code here


return 0;
}

 

Rectangle.cpp template

#include<iostream>
#include<stdlib.h>
using namespace std;

class Rectangle
{
private:
int length;
int breadth;


//Fill your code here

};

Write a C++ program to calculate the area of the rectangle using the friend function.
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class
names, member variable names, and function names should be the same as specified in the problem
statement. Create separate classes in separate files.
The class Rectangle has the following private attributes.
Data Type
Variable Name
length
breadth
int
int
Include appropriate getters and setters for the above class.
Define a function to find the area of a rectangle which will be able to access the private data members
of the Rectangle class.
Method
Description
void calcArea(Rectangle rec)
This function is used to calculate the area and display it.
In the main() method, read the length and breadth details from the user and display the area by calling
the function.
Input and Output Format:
Please refer to the sample input and output for formatting specifications.
[All text in bold are input and the remaining are output]
Sample Input and Output :
Enter the length
10
Enter the breadth
20
Area: 200
Transcribed Image Text:Write a C++ program to calculate the area of the rectangle using the friend function. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Create separate classes in separate files. The class Rectangle has the following private attributes. Data Type Variable Name length breadth int int Include appropriate getters and setters for the above class. Define a function to find the area of a rectangle which will be able to access the private data members of the Rectangle class. Method Description void calcArea(Rectangle rec) This function is used to calculate the area and display it. In the main() method, read the length and breadth details from the user and display the area by calling the function. Input and Output Format: Please refer to the sample input and output for formatting specifications. [All text in bold are input and the remaining are output] Sample Input and Output : Enter the length 10 Enter the breadth 20 Area: 200
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Database connectivity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr