Assignments PART A(40 points) 1. Start with the following code. Copy and paste in MVS and save as Lab 3. Run the code, observe the outputs and write descriptions for the sections/functions after...

please complete attached hw


Assignments PART A(40 points) 1. Start with the following code. Copy and paste in MVS and save as Lab 3. Run the code, observe the outputs and write descriptions for the sections/functions after “//”. #include using namespace std; class Rectangle { int width, height;// public: void set_values(int, int);// int area() const;// int peri() const;// void printArea() const;// Rectangle();// Rectangle(int, int);// }; Rectangle::Rectangle(int a, int b) {// set_values(a, b); } Rectangle::Rectangle()// { width = 0; height = 0; } void Rectangle::set_values(int x, int y) {// width = x; height = y; } int Rectangle::area() const// { return width*height; } int Rectangle::peri() const// { return 2 * width + 2 * height; } void Rectangle::printArea() const// { cout < "area="" of="" rectangle:="" "="">< width*height="">< endl;="" }="" int="" main()="" {="" rectangle="" rect;="" int="" w,="" h;="" cout="">< "enter="" width="" of="" the="" yard:="" "="" ;="" cin="">> w; cout < "enter="" height="" of="" the="" yard:="" ";="" cin="">> h; rect.set_values(w, h);// cout < "area:="" "=""><>< endl;="" cout="">< "perimeter:="" "="">< rect.peri()="">< endl;="" rectangle="" rectb;="" cout="">< "area:="" "="">< rectb.area()="">< endl;="" cout="">< "perimeter:="" "="">< rectb.peri()="">< endl;// rect.printarea();// return 0; } you will be adding a derived class “boxtype” to the base class “rectangle”. 2. your derived class will have the following features. i. a void member function; set_values for width, height and length of the box. ii. an integer member function to calculate volume of the box. iii. a void or integer member function to print the surface area of the box. iv. a default constructor with default values of 0s for 3 dimensions. v. a constructor to call set_values to return 3 dimensions. vi. a private data member integer length. 3. as you develop your code: i. you can simplify your base class functions as needed. take out or modify the base class member functions as needed. ii. you can run all the code including boxtype class definitions and implementation details along with modified driver function (main function). iii. you should have one main function to perform all necessary tasks including: 1. your driver function should ask user to provide the dimensions of the cube (width, height and length). 2. display the volume and surface area of the box. a sample output may look like: enter width of the yard in ft: 2 enter height of the yard in ft: 6 total area (sq-ft) : 12 perimeter in ft: 16 area of the yard: 12 enter width of the box in inch: 5 enter height of the box in inch: 4 enter length of the box in inch: 2 surface area of the box (in sq-inch): 76 volume of the box (in cubic-inch): 40 press any key to continue . . . part b (30 points) in this part, you will use the class rectangle and the derived class boxtype to perform following tasks. 1. use class rectangle to calculate how much it will cost to fertilize the total area of the yard when the width, height (since the original example started with the variables width and height, we kept the same notation) and unit square-feet cost numbers are supplied by the user. the fertilizer cost cold be $1.25 per square-ft. 2. use class rectangle to calculate how much it will cost to put a fence on the perimeter of a yard. unit cost of the yard could be $2.50 per foot. 3. use class boxtype to calculate the cost of a given box by using the surface area. the user will supply the dimensions of the box and the unit square price of the box (for simplicity, assume all in inch and the unit price is in square-inch). 4. use class boxtype to calculate the cost of filling the volume of the box with a specific type of liquid. again, the dimensions and unit cubic-inch price of the liquid will be given by the user. 5. all the above functionalities should be developed in the driver function and displayed to the user properly. part c (10 points) as mentioned previously, above class definitions, implementations and main functions can be developed as one program. in this part, you will separate the classes in the header files, implementation details in “.cpp” files, and main function as a separate driver file. you can do this, after running your program error free. the header file for boxtype should include:#include “rectangle.h” also avoid errors that may occur because of multiple inclusion of header file “rectangle.h” by including #ifndef h_rectangle (or #ifndef rectangle_h) #define h_rectangle … … #endif in the rectangle.h header file. make sure that proper descriptions and commenting is included with your code. endl;="" rect.printarea();="" return="" 0;="" }="" you="" will="" be="" adding="" a="" derived="" class="" “boxtype”="" to="" the="" base="" class="" “rectangle”.="" 2.="" your="" derived="" class="" will="" have="" the="" following="" features.="" i.="" a="" void="" member="" function;="" set_values="" for="" width,="" height="" and="" length="" of="" the="" box.="" ii.="" an="" integer="" member="" function="" to="" calculate="" volume="" of="" the="" box.="" iii.="" a="" void="" or="" integer="" member="" function="" to="" print="" the="" surface="" area="" of="" the="" box.="" iv.="" a="" default="" constructor="" with="" default="" values="" of="" 0s="" for="" 3="" dimensions.="" v.="" a="" constructor="" to="" call="" set_values="" to="" return="" 3="" dimensions.="" vi.="" a="" private="" data="" member="" integer="" length.="" 3.="" as="" you="" develop="" your="" code:="" i.="" you="" can="" simplify="" your="" base="" class="" functions="" as="" needed.="" take="" out="" or="" modify="" the="" base="" class="" member="" functions="" as="" needed.="" ii.="" you="" can="" run="" all="" the="" code="" including="" boxtype="" class="" definitions="" and="" implementation="" details="" along="" with="" modified="" driver="" function="" (main="" function).="" iii.="" you="" should="" have="" one="" main="" function="" to="" perform="" all="" necessary="" tasks="" including:="" 1.="" your="" driver="" function="" should="" ask="" user="" to="" provide="" the="" dimensions="" of="" the="" cube="" (width,="" height="" and="" length).="" 2.="" display="" the="" volume="" and="" surface="" area="" of="" the="" box.="" a="" sample="" output="" may="" look="" like:="" enter="" width="" of="" the="" yard="" in="" ft:="" 2="" enter="" height="" of="" the="" yard="" in="" ft:="" 6="" total="" area="" (sq-ft)="" :="" 12="" perimeter="" in="" ft:="" 16="" area="" of="" the="" yard:="" 12="" enter="" width="" of="" the="" box="" in="" inch:="" 5="" enter="" height="" of="" the="" box="" in="" inch:="" 4="" enter="" length="" of="" the="" box="" in="" inch:="" 2="" surface="" area="" of="" the="" box="" (in="" sq-inch):="" 76="" volume="" of="" the="" box="" (in="" cubic-inch):="" 40="" press="" any="" key="" to="" continue="" .="" .="" .="" part="" b="" (30="" points)="" in="" this="" part,="" you="" will="" use="" the="" class="" rectangle="" and="" the="" derived="" class="" boxtype="" to="" perform="" following="" tasks.="" 1.="" use="" class="" rectangle="" to="" calculate="" how="" much="" it="" will="" cost="" to="" fertilize="" the="" total="" area="" of="" the="" yard="" when="" the="" width,="" height="" (since="" the="" original="" example="" started="" with="" the="" variables="" width="" and="" height,="" we="" kept="" the="" same="" notation)="" and="" unit="" square-feet="" cost="" numbers="" are="" supplied="" by="" the="" user.="" the="" fertilizer="" cost="" cold="" be="" $1.25="" per="" square-ft.="" 2.="" use="" class="" rectangle="" to="" calculate="" how="" much="" it="" will="" cost="" to="" put="" a="" fence="" on="" the="" perimeter="" of="" a="" yard.="" unit="" cost="" of="" the="" yard="" could="" be="" $2.50="" per="" foot.="" 3.="" use="" class="" boxtype="" to="" calculate="" the="" cost="" of="" a="" given="" box="" by="" using="" the="" surface="" area.="" the="" user="" will="" supply="" the="" dimensions="" of="" the="" box="" and="" the="" unit="" square="" price="" of="" the="" box="" (for="" simplicity,="" assume="" all="" in="" inch="" and="" the="" unit="" price="" is="" in="" square-inch).="" 4.="" use="" class="" boxtype="" to="" calculate="" the="" cost="" of="" filling="" the="" volume="" of="" the="" box="" with="" a="" specific="" type="" of="" liquid.="" again,="" the="" dimensions="" and="" unit="" cubic-inch="" price="" of="" the="" liquid="" will="" be="" given="" by="" the="" user.="" 5.="" all="" the="" above="" functionalities="" should="" be="" developed="" in="" the="" driver="" function="" and="" displayed="" to="" the="" user="" properly.="" part="" c="" (10="" points)="" as="" mentioned="" previously,="" above="" class="" definitions,="" implementations="" and="" main="" functions="" can="" be="" developed="" as="" one="" program.="" in="" this="" part,="" you="" will="" separate="" the="" classes="" in="" the="" header="" files,="" implementation="" details="" in="" “.cpp”="" files,="" and="" main="" function="" as="" a="" separate="" driver="" file.="" you="" can="" do="" this,="" after="" running="" your="" program="" error="" free.="" the="" header="" file="" for="" boxtype="" should="" include:="" #include="" “rectangle.h”="" also="" avoid="" errors="" that="" may="" occur="" because="" of="" multiple="" inclusion="" of="" header="" file="" “rectangle.h”="" by="" including="" #ifndef="" h_rectangle="" (or="" #ifndef="" rectangle_h)="" #define="" h_rectangle="" …="" …="" #endif="" in="" the="" rectangle.h="" header="" file.="" make="" sure="" that="" proper="" descriptions="" and="" commenting="" is="" included="" with="" your="">
Mar 03, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here