C++ programming class. Please make as easy to understand as possible as this is
ID: 3632896 • Letter: C
Question
C++ programming class. Please make as easy to understand as possible as this is just a beginning course. Thanks!Design a class named Rectangle that represents a rectangle. The class should contain the following:
• Two private double data fields named “width” and “height” where the default width and height values are 1
• A no-arg constructor that creates a default rectangle
• A constructor that creates a rectangle with the specified width and height
• A method named getArea() that returns the area of this rectangle
• A method named getPerimeter() that returns the perimeter
• Two methods to get the width and height of the rectangle, named getWidth() and getHeight()
Using the newly created rectangle class, write a separate program that does the following:
• Ask user if they would like to create a default rectangle or if they want to enter width and height
• If they want to enter width and height, prompt them for these values
• Print the created rectangle's width, height, area, and perimiter
Explanation / Answer
#include #include using namespace std; class Rectangle { private: double width; double hight; public: //default constructor Rectangle() { width = 5; hight = 6; } Rectangle(int width, int hight); double getArea(); double getPerimeter(); double getwidth(); double gethight(); }; void main() { int choise, width, hight; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.