Question: Task: Write the full program that has the following main function. Your program should ask the user for Length and Width of a rectangle, and

Task: Write the full program that has the following main function. Your program should ask the user for Length and Width of a rectangle, and also for his choice: 1 or 2. If the user enters 1, then the program calculates the area of the rectangle. If the user enters 2, then the program calculates the perimeter of the rectangle. In the end, the program should display the area and the perimeter to the user.

(Hint: area=width*length & perimeter=2*( width+length))

int main()

{

int choice;

double L,W,Area, Perim;

readDimentions(L,W);

readChoice(choice);

if (choice==1)

Area=findArea(L,W);

else if (choice==2)

Perim=findPerim(L,W);

else

{

cout<<" You entered a wrong choice"<

return 0;

}

printResults(Area,Perim,choice);

return 0;

}

Functions:

  • void prinErrorMessage();

  • void printResults(double Area,double, Perim,int choice);

  • main() - it is given already, but you have to explain the program work flow in the presentation!

  • void readChoice(int& choice);

  • void readDimentions(double& L, double& W);

  • double findArea(double L, double W);

  • double findPerim(double L, double W);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!