Question: C++ CODE ONLY /* Do Programming Project 2 on page 611. You may watch the video note for * Programming Project 1 on page 611
C++ CODE ONLY /* Do Programming Project 2 on page 611. You may watch the video note for * Programming Project 1 on page 611 to get some idea. Then try to finish * independently by complete this sample file. * * Author: Your Name * Version: Date */ #includeusing namespace std; class CDAccount { public: CDAccount(); CDAccount(double new_balance, double new_interest_rate, int new_term); double get_initial_balance() const; double get_balance_at_maturity() const; double get_interest_rate() const; int get_term() const; void input(istream& in); void output(ostream& out); private: int dollar; int cent; double interest_rate; int term; // months until maturity }; int main() { // You implement the test code here // You may watch the video note to get the idea // notice that user will only enter balance as a double value // You may implement it as a menu oriented testing program // which be able to test constructors, methods of CDAccount class } // Implement the class definition here. Notice that the interfaces are the // same as in Programming Project 1. However, the implementation will be // different since the private information balance is stored differently // for example, the input function will only read the balance, itnerest rate // and term from the user. So it should be modified as following void CDAccount::input(istream& in) { double balance; in >> balance; // get initial balance from user // convert balance to dollars and cents since this is how balance stored dollar = (int) balance; // dollar is the interger part of balace cent = (int) ((balance - dollar)*100); // cent is the fraction part * 100 in >> interest_rate; // get interest rate from user in >> term; // get term from user }

1. Redefine CDAccount from Display 10.1 so that it is a class rather than a structure. Use the same member variables as in Display 10.1 but make them private. Include member functions for each of the following: one to return the initial balance, one to return the balance at maturity, one to return the interest rate, and one to return the term. Include a constructor that sets all of the member variables to any specified values, as well as a default constructor. Embed your class definition in a test program 2. Redo your definition of the class CDAccount from Practice Program 1 so that it has the same interface but a different implementation. The new implementation is in many ways similar to the second implementation for the class BankAccount given in Display 10.7. Your new implementation for the class CDAccount will record the balance as two values of type int: one for the dollars and one for the cents. The member variable for the interest rate will store the interest rate as a fraction rather than as a percentage. For example, an interest rate of 4.3% will be stored as the value 0.043 of type double. Store the term in the same wav as in Display 10.1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
