Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ PROGRAMMING PART A: PART B: CODE NEEDED: lab12_Q1.cpp: #include #include #include using namespace std; class Shape { public: virtual string getType() = 0; virtual
C++ PROGRAMMING
PART A:
PART B:
CODE NEEDED:
lab12_Q1.cpp:
#include#include #include using namespace std; class Shape { public: virtual string getType() = 0; virtual double getPerimeter() = 0; virtual double getArea() = 0; }; //Implement class Triangle here //Implement class Circle here void describeShape(Shape &s) { double a = s.getArea(); double p = s.getPerimeter(); string t = s.getType(); cout lab12_Q2.cpp:
#include#include using namespace std; class Shape { public: virtual string getType() = 0; virtual double getPerimeter() = 0; virtual double getArea() = 0; }; //Implement class Triangle here //Implement class Circle here void describeShape(Shape &s) { double a = s.getArea(); double p = s.getPerimeter(); string t = s.getType(); cout Download lab12 Q1 cpp. Triangles, and Circles are Shapes, geometric objects which can have their perimeter and area calculated. Implement a Shape abstract class, which can be used in the following mann void describeShape (Shape double area s.getArea0 string type s get Type0; double perim s.get Perimeter 0 cout "This type has a perimeter of perim and an area o area endl. The Shape class is provided for you. Implement Triangle and Circle classes and use the given driver program to produce the following output This Triangle has a perimeter of 12 and an area of: 6 This Circle has a perimeter of: 25.1328 and an area of: 50.2656 Press any key to continue Please do not modify the driver program. No state pertaining to the Triangle or Circle may be stored in the Shape objects. Use Heron's formula for calculating the area of a Triangle: A Nos (a b c)/2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started