Only in c++ please. Just need the solution code. Thank you. SavingsAccount is a class with two double* data members pointing to the amount saved and interest rate of the savings account, respectively. Two doubles are read from input to initialize mySavingsAccount. Write a copy constructor for SavingsAccount that creates a deep copy of mySavingsAccount. At the end of the copy constructor, output "Produced a new SavingsAccount object" and end with a newline. Ex: If the input is 78.00 1.00, then the output is: Produced a new SavingsAccount object Initial amount saved: $78.00 with 2.00 interest rate Produced a new SavingsAccount object After 1 month(s): $234.00 After 2 month(s): $702.00 After 3 month(s): $2106.00 After 4 month(s): $6318.00 After 5 month(s): $18954.00 Custom value interest rate $78.00 with 1.00 interest rate#include #include using namespace std; class SavingsAccount { public: SavingsAccount(double startingAmount = 0.0, double startingRate = 0.0); SavingsAccount(const SavingsAccount& acc); void SetAmount(double newAmount); void SetRate(double newRate); double GetAmount() const; double GetRate() const; void Print() const; private: double* amount; double* rate; }; SavingsAccount::SavingsAccount(double startingAmount, double startingRate) { amount = new double(startingAmount); rate = new double(startingRate); } /* Your code goes here */ void SavingsAccount::SetAmount(double newAmount) { *amount = newAmount; } void SavingsAccount::SetRate(double newRate) { *rate = newRate; } double SavingsAccount::GetAmount() const { return *amount; } double SavingsAccount::GetRate() const { return *rate; } void SavingsAccount::Print() const { cout << fixed << setprecision(2) << "$" << *amount << " with " << *rate << " interest rate" << endl; } void SimulateGrowth(SavingsAccount c, int months) { for (auto i = 1; i <= months; ++i) { c.SetAmount(c.GetAmount() * (c.GetRate() + 1.0)); cout << "After " << i << " month(s): " << "$" << c.GetAmount() << endl; } } int main() { double amount; double rate; cin >> amount; cin >> rate; SavingsAccount mySavingsAccount(amount, rate); SavingsAccount mySavingsAccountCopy = mySavingsAccount; mySavingsAccount.SetRate(rate + 1.0); cout << "Initial amount saved: "; mySavingsAccount.Print(); SimulateGrowth(mySavingsAccount, 5); cout << endl; cout << "Custom value interest rate" << endl; mySavingsAccountCopy.Print(); return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Only in c++ please. Just need the solution code. Thank you.

SavingsAccount is a class with two double* data members pointing to the amount saved and interest rate of the savings account, respectively. Two doubles are read from input to initialize mySavingsAccount. Write a copy constructor for SavingsAccount that creates a deep copy of mySavingsAccount. At the end of the copy constructor, output "Produced a new SavingsAccount object" and end with a newline.

Ex: If the input is 78.00 1.00, then the output is:

Produced a new SavingsAccount object Initial amount saved: $78.00 with 2.00 interest rate Produced a new SavingsAccount object After 1 month(s): $234.00 After 2 month(s): $702.00 After 3 month(s): $2106.00 After 4 month(s): $6318.00 After 5 month(s): $18954.00 Custom value interest rate $78.00 with 1.00 interest rate#include <iostream> #include <iomanip> using namespace std; class SavingsAccount { public: SavingsAccount(double startingAmount = 0.0, double startingRate = 0.0); SavingsAccount(const SavingsAccount& acc); void SetAmount(double newAmount); void SetRate(double newRate); double GetAmount() const; double GetRate() const; void Print() const; private: double* amount; double* rate; }; SavingsAccount::SavingsAccount(double startingAmount, double startingRate) { amount = new double(startingAmount); rate = new double(startingRate); } /* Your code goes here */ void SavingsAccount::SetAmount(double newAmount) { *amount = newAmount; } void SavingsAccount::SetRate(double newRate) { *rate = newRate; } double SavingsAccount::GetAmount() const { return *amount; } double SavingsAccount::GetRate() const { return *rate; } void SavingsAccount::Print() const { cout << fixed << setprecision(2) << "$" << *amount << " with " << *rate << " interest rate" << endl; } void SimulateGrowth(SavingsAccount c, int months) { for (auto i = 1; i <= months; ++i) { c.SetAmount(c.GetAmount() * (c.GetRate() + 1.0)); cout << "After " << i << " month(s): " << "$" << c.GetAmount() << endl; } } int main() { double amount; double rate; cin >> amount; cin >> rate; SavingsAccount mySavingsAccount(amount, rate); SavingsAccount mySavingsAccountCopy = mySavingsAccount; mySavingsAccount.SetRate(rate + 1.0); cout << "Initial amount saved: "; mySavingsAccount.Print(); SimulateGrowth(mySavingsAccount, 5); cout << endl; cout << "Custom value interest rate" << endl; mySavingsAccountCopy.Print(); return 0; } 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education