Question: Lang: C++. For this assignment, you will create a main.cpp file and a myshapes.h header file. A class will be defined for each shape described


Lang: C++.
For this assignment, you will create a main.cpp file and a myshapes.h header file. A class will be defined for each shape described below. Instances of the classes (objects) will be used in main to perform the specified calculations and the results will be printed out. 1. Create a header file named myshapes.h. In the header file, define the following 4 separate classes: Square, Rectangle, Circle, RightTriangle (for a right angled triangle). - The Square class should have private variables 'side' for the side length of the square, perimeter, and area (use double). There should also be public functions defined for the area and the perimeter of the square (you can calculate both using side length). You should also define a constructor within public (ex. Square(double side)) for the class that will take as input a double for the side length, and set the side length as such, and also calculate the values for perimeter, and area. You will use this when you create an object of type Square within main.cpp (ex. Square MySquare(4.5)). Finally, define a public member function that will print: "My square side length is [length you gave], the perimeter is [use function in class to calculate it], the area is [use function in class to calculate it]. - The Rectangle class should have private variables 'height' and 'width' for the corresponding side lengths, and perimeter, and area (use double). There should also be public functions defined for the area and the perimeter of the rectangle (you can calculate both using the width and height). You should also define a constructor within public (ex. Rectangle(double height, double width)) for the class that will take as input doubles for the height and width, and set the variables within the class as such, and also calculate the values for perimeter, and area. You will use this when you create an object of type Rectangle within main.cpp (ex. Rectangle MyRectangle(4.5, 5.5)). Finally, define a public member function that will print: "My rectangle height is [height you gave] and width is [width you gave], the perimeter is [use function in class to calculate it], the area is [use function in class to calculate it]. - The RightTriangle class should have private variables 'height' and 'width' for the corresponding side lengths, and perimeter, and area (use double). There should also be public functions defined for the area and the perimeter of the right angled triangle (you can calculate both using the width and height, you'll need Pythogorean Theorem for the hypotenuse to get the perimeter). You should also define a constructor within public (ex. RightTriangle(double height, double width)) for the class that will take as input doubles for the height and width, and set the variables within the class as such, and also calculate the values for perimeter, and area. You will use this when you create an object of type Right Triangle within main.cpp (ex. RightTriangle MyRightTriangle(4.5, 5.5)). Finally, define a public member function that will print: "My right angled triangle's height is [height you gave] and width is [width you gave], the perimeter is [use function in class to calculate it], the area is [use function in class to calculate it]. - The Circle class should have private variables 'radius' for the radius of the circle, and circumference, and area (use double). There should also be public functions defined for the area and the circumference of the circle (you can calculate both using radius). You should also define a constructor within public (ex. Circle(double radius)) for the class that will take as input a double for the radius, and set the radius as such, and also calculate the values for circumference and area. You will use this when you create an object of type Circle within main.cpp (ex. Circle MyCircle(10)). Finally, define a public member function that will print: "My circle radius is [radius you gave], the circumference is [use function in class to calculate it], the area is [use function in class to calculate it]. 2. In main.cpp, before declaring objects for each of the classes (Square, Rectangle, RightTriangle, Circle), ask the user to enter the appropriate parameters for each shape. That is, first you will ask "Enter a side length for a square", then using that value you create an object of type Square with those parameters, then ask the user to enter the parameters for a rectangle etc. After all parameters are entered and objects are created, execute the print functions for each shape to print the parameters entered and calculated perimeter/circumference and area
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
