Question

Complete the Rectangle Program Using the code given in rectangle.cpp, implement the functions that are called...

Complete the Rectangle Program 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

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Complete the Rectangle Program Using the code given in rectangle.cpp, implement the functions that are called...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the...

    Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the following 3 methods: Method isValid() returns true if the sum of the width and height is greater than 30 Method Area() returns the area of the rectangle if it is a valid rectangle Method Perimeter() returns the perimeter of the rectangle if it is a valid rectangle The main method of MyRectangle prompts the user to enter the width and height of a rectangle...

  • Develop a complete C++ program that will calculate draw an empty cube rectangle using a function...

    Develop a complete C++ program that will calculate draw an empty cube rectangle using a function call. A rectangle is identified by length of its edges, 2 <= L <= 20. Implement a function to perform user request, which requires two parameter. The functions you define should not return a value. In main() function, design a loop to ask user to enter length of edges until user enters 0 for one of the edges. A length of 0 exits the...

  • // This program uses the programmer-defined Rectangle class. #include "Rectangle.cpp" #include <iostream> using namespace std; int...

    // This program uses the programmer-defined Rectangle class. #include "Rectangle.cpp" #include <iostream> using namespace std; int main() {    Rectangle rectangle1;    Rectangle rectangle2;    rectangle1.setLength(10.0);    rectangle1.setWidth(5.0);    rectangle2.setLength(7.0);    rectangle2.setWidth(3.0);    cout << "Perimeter of rectangle1 is " << rectangle1.calculatePerimeter() << endl;    cout << "Area of rectangle1 is " << rectangle1.calculateArea() << endl;    cout << "Perimeter of rectangle2 is " << rectangle2.calculatePerimeter() << endl;    cout << "Area of rectangle2 is " << rectangle2.calculateArea() << endl;...

  • Description Create an object-oriented program that uses inheritance to perform calculations on a rectangle or a...

    Description Create an object-oriented program that uses inheritance to perform calculations on a rectangle or a square. Sample Output (Your output should be similar to the text in the following box) Rectangle Calculator Rectangle or square? (r/s): r Height: 5 Width: 10 Perimeter: 30 Area: 50 Continue? (y/n): y Rectangle or square? (r/s): s Length: 5 Perimeter: 20 Area: 25 Continue? (y/n): n Thank you for using my app Specifications Use a Rectangle class that provides attributes to store the...

  • C++ program. int main() {    Rectangle box;     // Define an instance of the Rectangle class...

    C++ program. int main() {    Rectangle box;     // Define an instance of the Rectangle class    double rectWidth; // Local variable for width    double rectLength; // Local variable for length    string rectColor;    // Get the rectangle's width and length from the user.    cout << "This program will calculate the area of a\n";    cout << "rectangle. What is the width? ";    cin >> rectWidth;    cout << "What is the length? ";    cin >>...

  • JAVA Code Requried Copy the file java included below. This program will compile, but, when you...

    JAVA Code Requried Copy the file java included below. This program will compile, but, when you run it, it doesn’t appear to do anything except wait. That is because it is waiting for user input, but the user doesn’t have the menu to choose from yet. We will need to create this. Below the main method, but in the Geometry class, create a static method called printMenu that has no parameter list and does not return a value. It will...

  • Using basic c++ write a separate code for each of the following: 1. Area Rectangle •...

    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...

  • Modify the C++ program you created in assignment 1 by using 'user defined' functions. You are...

    Modify the C++ program you created in assignment 1 by using 'user defined' functions. You are to create 3 functions: 1. A function to return the perimeter of a rectangle. This function shall be passed 2 parameters as doubles; the width and the length of the rectangle. Name this function and all parameters appropriately. This function shall return a value of type double, which is the perimeter. 2. A function to return the area of a rectangle. This function shall...

  • Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept...

    Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept of a 5-digit palindrome number is a 5-digit number that reads the same from left to right and from right to left. For example, 12121, 45454, and 14741 are valid 5-digit palindrome numbers. Design (pseudocode) and implement (source code) a program (name it FiveDigitPalindrom) that reads a 5-digit number from the user (as integer value, not string) and then mathematically (using division and remainder...

  • Construct a C++ class named Rectangle that has floating-point data members named length and width.  The class...

    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,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT