In this exercise, you modify the Rectangle class from Lab 15-2 so that its setDimensions method returns

Question:

In this exercise, you modify the Rectangle class from Lab 15-2 so that its setDimensions method returns a value. You also modify the Terney Landscaping program. 

a. If necessary, create a new project named Intermediate16 Project and save it in the Cpp8\Chap15 folder. Copy the instructions from the Lab15-2.cpp file into a source file named Intermediate16.cpp. Change the filename in the first comment. 

b. Copy the instructions from the Lab15-2 Rectangle.h file (which is located in either the Cpp8\Chap15\Lab15-2 Project folder or the Cpp8\Chap15 folder) into a header file named Intermediate16 Rectangle.h file. Change the filename in the first comment. 

c. Modify the setDimensions method so that it returns a value that indicates whether the length and width dimensions passed to the method are valid. To be valid, each dimension must be greater than 0.0. If the setDimensions method indicates that the length and width dimensions are valid, the program should calculate and display both the area and the total price; otherwise, it should display an error message. Modify the program appropriately. 

d. Save and then run the program. Test the program using 120 feet as the length, 75 feet as the width, and 1.55 as the price. The program should display 1000.00 as the area in square yards and $1550.00 as the total price. Now, run the program again. Enter –5 as the length, 6 as the width, and 3 as the price. The program should display an error message because the length dimension is less than 0.0.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: