>>>>>>>>>>>>>>>>> (THIS IS FOR THE QUESTION BELOW) Write a class to represent a bank account to which one may make deposits (with the += operator), from which one may make withdrawals (with the -= operator), and from which one can get a report of the current balance (with the method balance()). Below is some sample code, where the account is opened with an initial deposit of $50. Account x(50); x+=23; cout<<"The account has $"<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #include using namespace std; class Account{ public: Account(double j=0); Account & operator+=(double j); Account & operator-=(double j); double balance()const; private: double money; void check(bool b, char *mess); }; (sp07f) 7. Write a subclass of the class Account (see above), called Savings, that pays interest at some given rate (per month). An instance of Savings responds to the message post() by accruing (simple) interest for the given number of months. Below is some sample code (where "<<" has been overloaded for instances of Savings). Savings s(0.01), //open an account with $0 deposit and monthly interest //of 1% t(0.015,50); //open an account with $50 deposit and monthly interest //of 1.5% s+=1000; s.post(10); //add 10 months of interest (not compounded) cout<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> class Savings:public Account{ public: Savings(double intRate=0,double amt=0); void post(int m); friend ostream & operator<<(ostream & out,const Savings & s); private: double rate; }; Savings::Savings(double intRate, double amt):Account(amt),rate(intRate){ check(rate>=0 && rate<=1,"Rate must be between 0 and 1, inclusive"); } void Savings::post(int m){ check(m>0,"Must have positive number of months"); money+=m*rate*money; } ostream & operator<<(ostream & out,const Savings & s){ out<<"Savings("< using namespace std; class DisplayRect:public Rectangle{ public: static const int RED=0, GREEN=1, BLUE=2; DisplayRect(double w, double h,int c); double area()const; friend ostream & operator<<(ostream &out,const DisplayRect &d); private: int color; static void check(bool b,char * mess); }; DisplayRect::DisplayRect(double w, double h,int c):Rectangle(w,h),color(c) {check(c>=RED && c<=BLUE,"Color out of range");} double DisplayRect:: area()const {return getHeight()*getWidth();} ostream & operator<<(ostream &out,const DisplayRect &d) {char *col[]={"Red","Green","Blue"}; out<<"{Width: "<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4. Add a function display() to the class A below and write a subclass B of class A. The only purpose of class B is to override the function display() in class A (and class B should do nothing more than that). If we have A a(2,4); B b(2,4); then a.display() produces 2, 4 while b.display() produces [2,4]. Further, b.x(), should produce -->[2,4] class A {public: A(int a=0, int b=0):s(a),t(b){} void x(){cout<<"-->"; display();} private: int s,t; }; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> in the public section of class add: virtual void display(); class B:public A {public: B(int a=0, int b=0); void display(); }; void A::display(){cout<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (s06f) 4. Before answering this question read question 5, a related question. Write the declaration and definition (code) for the class LUAcc which is meant to store information for LTS user accounts: the first name, the last name, and the user identifier. It should have sufficient functionality so that the code below produces the indicated output. Your class need only store the first 15 characters of a name, discarding the rest, and can assume all user identifiers have six or fewer characters. LUAcc x("Tom", "Mix", "TM203"); cout<0) out<<", "; out<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (f05t1) 1. The class Counter below is meant to model a hand held counter. It starts out at 0 and can be reset to 0. Each "click" increments the count by 1. Write a subclass XCounter which adds some functionality by allowing it to be incremented or decremented by numbers other than 1, using the += and -= operators. First I show the class Counter, and then I show how the code for XCounter could be used. class Counter {public: Counter(); void click(); //increment counter by 1 void reset(); //set counter to 0 int getCount()const; //return the count on the counter private: int count; }; //Sample code for XCounter XCounter ct; ct+=5; //increment counter by 5 ct-=3; //decrement counter by 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< class XCounter : public Counter {public: XCounter(){} XCounter& operator+=(int n); XCounter& operator-=(int n); private: static void check(bool b, char *mess); }; XCounter & XCounter::operator +=(int n) {check(n>0,"Can't increment with 0 or negative n"); for(int j=0;j0,"Can't decrement with 0 or negative n"); save=getCount(); check(save-n>=0,"Decrement is too large"); reset(); for(int j=0;j>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (f05f) 4. Below is the declaration for the class List, which is meant to maintain a list of integers. Write the declaration and definitions (code) for a sublcass, MyList, that adds the method sort(), which sorts the list in ascending order, and the operator +=, which adds an int to the end of the list. With your class, the sample code should compile and produce the indicated output. class List {public: List(int n=100); //a list of n entries; error if n<1 void add(int n); //add n to the end of the list int length()const; //number of entries in list int capacity()const; //maximum number of entries int & at(int n); //get entry at location n static void check(bool b, char *mess); private: int *data; int max, //maximum number of items in list count; //number of items in list }; MyList p(20); for(int j=0; j<5; j++) p+=(j-2)*(j-2); p.sort(); for(int j=0; j<5; j++) cout< class MyList: public List {public: MyList(int n=100); void sort(); MyList & operator +=(int n); private: void swap(int &a, int &b,bool &c); }; MyList::MyList(int n):List(n){} MyList & MyList::operator +=(int n) {add(n); return *this; } void MyList::sort() {bool sorted; do {sorted=true; for(int j=1; jat(j)) swap(at(j-1),at(j),sorted); } while(!sorted); } void MyList::swap(int & a, int &b,bool &c) {int temp; temp=a; a=b; b=temp; c=false; } >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4. The declaration for the class Rectangle below is meant to represent a geometric rectangle. Write declaration and definitions (code) for Box, a subclass of the class Rectangle so that the code below the declaration has the indicated affect. class Rectangle {public: Rectangle(int lngth=10, int wide = 10); int getLength()const; int getWidth()const; int getArea()const; private: int length,width; }; Box a(2,3,4); cout<<"The box "<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (f03t1) 3. Given the class A below, write the declaration and the definition (code) for the class B that is a subclass of the class A and for which the following code outputs the sum of the variables x and y. class A A::A(int a, int b) {public: {x=a; A(int a=0,int b=0); y=b; int getX(); } int getY(); int A::getX() private: {return x;} int x, y; int A::getY() }; {return y;} B u(2,3); cout<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (s03f) 8. Given the class D below create a subclass E of D so that the code in the program compiles and produces the output indicated. Give both the declaration of E and the definition (code). class D {public: D(int a=0){x=a;} protected: int x; }; int main() {E u(2),v(3); cout<