CHAPTER 10 Object-Oriented C++ method to calculate and return the area of the rectangle and the perimeter of the Write a public calculateArea() method and a public calculatePerimeter(). 6. Save this class file, Rectangle.cpp, in a directory of your choice, and then open the rectangle. a file named MyRectangleClassProgram.cpp. 7. In the MyRectangleClassProgram, create two Rectangle objects named rectanglel and rectangle2 using the default constructor as you saw in MyEmployeeClassProgram.cpp. 8. Set the length of rectanglel to 10.0 and the width to 5.0. Set the length of Print the value of rectangle1's perimeter and area, and then print the value of rectangle2 to 7.0 and the width to 3.0. rectangle2's perimeter and area. L con in the same directory as Rectangle.com
// Rectanlge.cppusing namespace std;class Rectangle{ public: // Declare public methods here private: // Create length and width here}; void Rectangle::setLength(double len){ // Write setLength here}void Rectangle::setWidth(double wid){ // write setWidth here}double Rectangle::getLength(){ // write getLength here}double Rectangle::getWidth(){ // write getWidth here}double Rectangle::calculateArea(){ // write calculateArea here}double Rectangle::calculatePerimeter(){ // write calculatePerimeter here}
// This program uses the programmer-defined Rectangle class. #include "Rectangle.cpp"#include <iostream>using namespace std; int main(){ // Create Rectangle objects here // Set the lengths and widths here // Print the areas and perimeters here return 0;}
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 3 images