create one base class Shape and three child classes Circle, Square, and Triangle with the following data members and mem

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

create one base class Shape and three child classes Circle, Square, and Triangle with the following data members and mem

Post by answerhappygod »

create one base class Shape and three child classes Circle,
Square, and Triangle with the following data members and member
functions, Protected Data Members of class Shape such as: c_radius,
s_area, s_length, s_width, t_base, t_height (int) c_area, t_area
(float) pie = 3.1416 (const int) Public Member Functions of class
Shape such as: void calculateArea() – It will print “Parent Class
is generic”. void Display() – It will print “Your Name and Roll
Number. Inherited Data Members of class Circle such as: It will
inherit c_radius and c_area from shape class. Public Member
Functions of class Circle such as: void calculateArea() – It will
take input c_radius and calculate area and display area of the
circle. void Display() – It will take input c_radius and calculate,
store in c_area and display area of the circle. Inherited Data
Members of class Square such as: It will inherit s_length, s_width
and s_area from shape class. Public Member Functions of class
Square such as: int calculateArea(int a) – It will initialize
s_length and s_width with a and calculate and return area of the
square. void Display() – It will take input s_length and s_width
and calculate area, store in s_area and display area of the square.
Inherited Data Members of class Triangle such as: It will inherit
t_base, t_height and t_area from shape class. Public Member
Functions of class Triangle such as: float calculateArea(int b, int
h) – It will initialize t_base and t_height with b and h and
calculate and return area of the triangle. void Display() – It will
take input t_base and t_height and calculate area, store in t_area
and display area of the triangle. Create a UML diagram. Do the
following operations in main function: 1. Create objects of class
Shape, Circle, Square, and Triangle and call member function
calculateArea(). Write below its function overloading or function
overriding. Ans: 2. Create objects of class Shape, Circle, Square,
and Triangle and call member function Display(). Write below its
function overloading or function overriding. Ans:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply