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;
}