Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete and most simplistic C++ code for: MetroP \'11-29% 4:29PM n the

ID: 3736836 • Letter: W

Question

Write a complete and most simplistic C++ code for:

MetroP '11-29% 4:29PM n the comment, at the very beginning of the sour mber and name (COP 2272C-02 Computer Progr time of last successful debugging. Without this, Subject Wite a Cmplte C peeom thel defs umpoments, and tests all 3 classes in the Clas tree shown m the dingam. Here Tre chss is the supercla ss. t h as two Swbdlasses cocomt re and illow All prperties are ru Fist, code there classes, like what we did 'n OOB Irst, code Pyperties utca Methds 2 set and z set methods ontr uc to disploy) pyint curert valnes N arqu Stardard all properties rou) n retun, pint tho. tree's grouth rate,eq. inches Metho

Explanation / Answer

#include <iostream>

using namespace std;

class Tree {
public:
int age;
double height;
Tree(int age1, double height1) {
age=age1;
height=height1;
}
void setage(int age2) {
age=age2;
}
int getage() {
return age;
}
void setheight(int height2) {
height=height2;
}
int getheight() {
return height;
}
void display() {
cout<<"Age=" << age<<endl;
cout<<"Height=" << height<<endl;
}
void grow() {
cout<<"Growth rate=" << (height/age)<<endl;
}
};
class CoconutTree : public Tree {
private:
int nutNumber;
int leafHeight;
public:
CoconutTree(int nutNumber1, int leafHeight1, int age1, double height1) : Tree(age1, height1) {
nutNumber=nutNumber1;
leafHeight=leafHeight1;
}
void setnutNumber(int nutNumber2) {
nutNumber=nutNumber2;
}
int getnutNumber() {
return nutNumber;
}
void setleafHeight(int leafHeight2) {
leafHeight=leafHeight2;
}
int getleafHeight() {
return leafHeight;
}
void display() {
cout<<"Age=" << age<<endl;
cout<<"Height=" << height<<endl;
cout<<"Number of Nuts= " << nutNumber<<endl;
cout<<"Height of leaf= " << leafHeight<<endl;
}
void bendGrowth(){
cout<<"Bend Growth= " << (nutNumber/leafHeight)<<endl;
}
};

class Willow : public Tree {
private:
int numBranch;
int flexibility;
public:
Willow(int numBranch1, int flexibility1, int age1, double height1) : Tree(age1, height1) {
numBranch=numBranch1;
flexibility=flexibility;
}
void setnumBranch(int numBranch2) {
numBranch=numBranch2;
}
int getnumBranch() {
return numBranch;
}
void setflexibility(int flexibility2) {
flexibility=flexibility2;
}
int getflexibility() {
return flexibility;
}
void display() {
cout<<"Age=" << age<<endl;
cout<<"Height=" << height<<endl;
cout<<"Number of Branches= " << numBranch<<endl;
cout<<"Flexibility= " << flexibility<<endl;
}
void swing() {
cout<<"Swing=" << (numBranch/flexibility)<<endl;
}
};

int main() {
CoconutTree coco(6,4,1,2);
coco.display();
coco.grow();
coco.bendGrowth();
Willow ww(8,5,3,7);
ww.display();
ww.grow();
ww.swing();
};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote