Using the code given in rectangle.cpp, implement the functions that are called in the main function to complete the program. You must not change any of the existing code in the file. You can only add functions and comments to the code.

Here's a sample run of how the program should behave:

Enter rectangle length: -1 <-- invalid value, ask user to re-enter
Enter rectangle length: -2 <-- invalid value
Enter rectangle length: 0 <-- invalid value
Enter rectangle length: 3 <-- valid, accept
Enter rectangle width: -5 <-- invalid value
Enter rectangle width: 0 <-- invalid value
Enter rectangle width: 5 <-- valid, accept
Rectangle Data
--------------
Length: 3
Width: 5
Area: 15
Perimeter: 16

Notes:

1. any length and width values less than or equal to zero are ignored and the user is asked to re-enter the value

Source code to complete:

/*
* This program computes the area and perimeter of a rectangle
* given the length and width.
*
* CS1160 - Assignment 6
* Author: < your name here>
*/
#include < iostream>
using namespace std;

void getLengthAndWidth(double&, double&);
double calcArea(double, double);
double calcPerimeter(double, double);
void displayData(double, double, double, double);

int main()
{
double length, width, area, perimeter;

// get the length and the width from the user
getLengthAndWidth(length, width);

// calculate the area of the rectangle
area = calcArea(length, width);

// calculate the perimeter of the rectangle
perimeter = calcPerimeter(length, width);

// display above data to the user
displayData(length, width, area, perimeter);

return 0;
}
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.