Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to ask theuser to enter the width and length of a rectangle, and

ID: 3614717 • Letter: W

Question

Write a program to ask theuser to enter the width and length of a rectangle, and displaythe

rectangle’s area.The main function in this program should call the followingfunctions:

getLength – thisfunction should ask the user to enter the rectangle’s length,and then return

that values as adouble.

getWidth – thisfunction should ask the user to enter the rectangle’s width,and then return

that values as adouble.

getArea – thisfunction should accept the rectangle’s length and width asarguments, and then

return therectangle’s area. The area is calculated by multiplying thelength by width.

displayData – thisfunction should accept the rectangle’s length, width, andarea as

arguments, and then display them in anappropriate message on the screen.

Explanation / Answer

//Hope this will helpyou. #include<iostream>
using namespace std;
double getLength(){
       double d;
       cout<<"Enterlength:";
       cin>>d;
       return d;
       }
double getWidth(){
       double d;
       cout<<"EnterWidth:";
       cin>>d;
       return d;
       }
double getArea(double l,double w)
{
return l*w;
}
void displayData(double l,double w,double a)
{
     cout<<"Area of rectangle withlen="<<l<<" & width = "<<w<<" is"<<a<<endl;
}
int main()
{
double l,w,a;
l=getLength();
w=getWidth();
a=getArea(l,w);
displayData(l,w,a);
   
    system("pause");
   
}
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote