Write a program to display the area of a rectangle after
accepting its length and width from the user by means of the
following functions:
getLength – ask user to enter the length and return it as
double
getWidth – ask user to enter the width and return it as
double
getArea – pass width and length, compute area and return area
displayArea – pass area and display it in this function.
Expected Output:
(i)
Enter the length: 29
Enter the width: 34
Rectangle Data
--------------
Length: 29
Width: 34
Area: 986
(ii)
Enter the length: 5.98
Enter the width: 29.345
Rectangle Data
--------------
Length: 5.98
Width: 29.345
Area: 175.483
#include <iostream>
#include <iomanip>
using namespace std;
double getLength();
double getWidth();
double getArea(double l,double w);
void displayArea(double area);
int main()
{
double l,w,area;
l=getLength();
w=getWidth();
area=getArea(l,w);
cout<<"Rectangle Data"<<endl;
cout<<"--------------"<<endl;
cout<<"Length:"<<l<<endl;
cout<<"Width:"<<w<<endl;
displayArea(area);
return 0;
}
double getLength()
{
double len;
cout<<"Enter the length:";
cin>>len;
return len;
}
double getWidth()
{
double width;
cout<<"Enter the width:";
cin>>width;
return width;
}
double getArea(double l,double w)
{
return l*w;
}
void displayArea(double area)
{
cout<<"Area:"<<area<<endl;
}
_______________
Output:

_____________Thank You
Write a program to display the area of a rectangle after accepting its length and width...
Using basic c++ write a separate code for each of the following: 1. Area Rectangle • Write a program that asks the user to enter length and width of a rectangle and then display the rectangles area. • Write the following functions • getLength – prompt the user to enter length and return that value as a double • getWidth – prompt the user to enter width and return that value as a double • getArea – This method should...
Use DevC++ to implement a program uses objected oriented programming to calculate the area of a rectangle. The program should create a Rectangle class that has the following attributes and member functions: Attributes: width and length Member functions: setWidth(), setLength(), getWidth() , getLength(), getArea() Where width and length are the respect width and length of a Rectangle class. The setWidth() and setLength() member function should set the length and width, the getWidth(), getLenght(), and getArea() member function should get the...
Use C++ to implement a program uses objected oriented programming to calculate the area of a rectangle. The program should create a Rectangle class that has the following attributes and member functions: Attributes: width and length Member functions: setWidth(), setLength(), getWidth() , getLength(), getArea() Where width and length are the respect width and length of a Rectangle class. The setWidth() and setLength() member function should set the length and width, the getWidth(), getLenght(), and getArea() member function should get the...
Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate rectangle area. Some requirements: 1. User Scanner to collect user input for length & width 2. The formula is area = length * width 3. You must implement methods getLength, getWidth, getArea and displayData ▪ getLength – This method should ask the user to enter the rectangle’s length and then return that value as a double ▪ getWidth – This method should ask the...
I need help with the C++ for the following problem: Write a program uses objected oriented programming to calculate the area of a rectangle. The program should create a Rectangle class that has the following attributes and member functions: Attributes: width and length Member functions: setWidth(), setLength(), getWidth() , getLength(), getArea() Where width and length are the respect width and length of a Rectangle class. The setWidth() and setLength() member function should set the length and width, the getWidth(), getLenght(),...
share your program enhance your work after submitting export to repl Due: Oct 12, 2020 05:00 pm submit : back to classroom run Instructions from your teacher: #include <iostream> Complete this program. using namespace std; When the program is complete it should ask the user to enter a rectangle's length and width, then display the rectangle's area. The program calls the following functions which need to be completed: double getLength() { // Add code here } double getWidth() { //...
In the code (C++) below, if you input 2 as length and 4 as width, the output is: Enter the rectangle's length: 2 Enter the rectangle's width: 4 Length: 2 | Width: 4 | Area: 8 | Perimeter:12 We worked on this code during class, but there were some things that I did not understand. 1) how does compiler read"l" as length, "w" as width, etc.? I thought you had to update it first, like "w=width." 2) i thought you...
Construct a C++ class named Rectangle that has floating-point data members named length and width. The class should have a zero-argument constructor that initializes each data member to 0. It should have member functions named calcPerimeter() and calcArea() that calculate the perimeter and area of a rectangle respectively, a member function setLength() and setWidth() to set the length and width, member functions getLength() and getWidth() to return the length and width, and a member function showData() that displays the rectangle’s length,...
Hello I have a question. I would like to check if the code follows this requirement. Rectangle.h - A complete Rectangle Class including both declaration and definition appRectangle,cpp separate in two different files the class definition and implementation Code: rectangle.h // Rectangle class declaration. class Rectangle { private: double width; double length; public: void setWidth(double); void setLength(double); double getWidth() const; double getLength() const; double getArea() const; }; //************************************************** // setWidth assigns a value to the width member. * //************************************************** void...
My assignment is to create a rectangle class in java. •Create a MyRectangleClass •There are two private instance variables, length l and width w with double data type. •There is a constructor with two parameter •There are 4 public methods which are circumference, area, getWidth, and getLength. •circumference method will return circumference to the caller.(the formula for circumference is 2 *l + 2*w ) •Area method Return the area to the caller(:l*w) •getLength method will return length to the caller....