Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help to build a c++ program using visual studio. It gotta have the output of the 2nd pic. Using the exercise of the pics

Need help to build a c++ program using visual studio. It gotta have the output of the 2nd pic. Using the exercise of the pics 3-6 .help please.Thanks! image text in transcribed
image text in transcribed
Following the the exercise pics
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Shape Inheritance (member fiunctions) - from Shape Base Classes Complete the e ndpeInheritance-Square Exercise. Exercise the new Square class in the Shapelnhe Change the project folder name to Assign0b-Shapelnheriance xercise project ShapeInheritance. Finish the project by adding the modules deseribed in the ercise. Exercise the new Square class in the Shapelnheritance.cpp module Define const PI in Circle.h const double PI-3.1416; Add public member function prototypes to both Rect.h and Circle.h header files. Make them const functions that return calculated values of type double. Add these member functions to both Circle.h and Rect.h double getArea() double getPerimeter() const; lux. Do not add to Sguare.h class definition. Implement these two methods as const functions in both the Cireleapp and the Rect.cpp source files: Rect double getArea() Rect double getPerimeter) cons Circle double getarea) return width height return 2- (width + height) return ?-radius" return t 2 radius const Circle double getPerimeter() cnst The Square class inherits getAreal) and getPerimeter() functions from the Rect class. The getPerimeter) and getArea() operations that Square inherits from Rect use both length and height values from Rect for these calculations. The class constructor for Square shows inheritance from Rect and invokes the Reet constructor, setting both length and height to the current value of the Square side. Square::Square(int newx, int newy, int length) Rect(newx, newy, length, length) Square side length used to set both Rect width and height setSide(length); When the current side value of a Square object is changed by Square.setSidetn), further coding is required to make a corresponding change in Rect base class data member values. Otherwise, underlying Rect values used to calculate area and perimeter for a Square object will be wrong and lead to an incorrect result. oid Square::setside (int newLength) side = newLength; Rect::sethidth(newLength); Rect::setHeight (newLength); // change width in Rect base class /l change height in Rect base class odify the display) routine for each of the derived Shape classes (Rect, Circle, and Square) and configure utput lines to fit all information across the output window. Show calculated area and perimeter values for ach of these shapes. or consistent formatting, these double values will require an extra statement at the start of all three of the oject display routines (Rect, Circle, and Square): coutfixed s setprecision(3); stream setw(8) in front of the double values (retuned by getArea() and getperineter)) the output stream of all three displayO routines

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions