C++ Program help! Typically, everyone saves money periodically for retirement, buying a house, or for some other purposes. If you are saving money for retirement, then the money you put in a retirement fund is tax sheltered and your employer also makes some contribution into your retirement fund. In this exercise, for simplicity, we assume that the money is put into an account that pays a fixed interest rate, and money is deposited into the account at the end of the specified period. Suppose that a person deposits R dollars’ m times a year into an account that pays r % interest compounded m times a year for t years. Then the total amount accumulated at the end of t years is given by Math Figure For example, suppose that you deposit $500 at the end of each month into an account that pays 4.8% interest per year compounded monthly for 25 years. Then the total money accumulated into the account is 500[(1 + 0.048/12)³⁰⁰ - 1]/(0.048/12) = $289,022.42. On the other hand, suppose that you want to accumulate S dollars in t years and would like to know how much money, m times a year, you should deposit into an account that pays r% interest compounded m times a year. The periodic payment is given by the formula Math Figure Instructions Design a class that uses the above formulas to determine the total amount accumulated into an account and the periodic deposits to accumulate a specific amount. Your class should have instance variables to store the periodic deposit, the value of m, the interest rate, and the number of years the money will be saved. Add appropriate constructors to initialize instance variables, functions to set the values of the instance variables, functions to retrieve the values of the instance variables, and functions to do the necessary calculations and output results. Also, write a program to test your class.
Screenshot
---------------------------------------------------------------------------------
Program
AmountAccumulate.h
#include<iostream>
#include<cmath>
using namespace std;
//Create a class
class AmountCalculate
{
///Member functions
public:
//Default constructor
AmountCalculate();
//Parameterized constructor
AmountCalculate(double,double,int);
//Destructor
~AmountCalculate();
//Setters
void setAmt(double);
void setInterest(double);
void setYear(int);
//Getters
double getAmt();
double getInterest();
int getYear();
//Method to calculate accumulated amount
double Calculate();
//Print details
void print();
//Instance variables
private:
double periodicAmt;
double interest;
int year;
};
AmountAccumulate.cpp
#include "AmountAccumulate.h"
AmountCalculate::AmountCalculate()
{
//Default constructor
periodicAmt = 0;
interest = 0;
year = 0;
}
//Destructor
AmountCalculate::~AmountCalculate()
{
}
//Parameterized constructor
AmountCalculate::AmountCalculate(double amt, double ir, int yr)
{
if (amt < 0) {
periodicAmt = 0;
}
else {
periodicAmt = amt;
}
if (ir < 0) {
interest = 0;
}
else {
interest = ir;
}
if (yr < 0) {
year = 0;
}
else {
year = yr;
}
}
//Setters
void AmountCalculate::setAmt(double amt) {
if (amt < 0) {
periodicAmt = 0;
}
else {
periodicAmt = amt;
}
}
void AmountCalculate::setInterest(double ir) {
if (ir < 0) {
interest = 0;
}
else {
interest = ir;
}
}
void AmountCalculate::setYear(int yr) {
if (yr < 0) {
year = 0;
}
else {
year = yr;
}
}
//Getters
double AmountCalculate::getAmt() {
return periodicAmt;
}
double AmountCalculate::getInterest() {
return interest;
}
int AmountCalculate::getYear() {
return year;
}
//Method to calculate accumulated amount
double AmountCalculate::Calculate() {
return periodicAmt * (pow((1 + (interest / 100) / 12),
(12 * year)) - 1) / ((interest / 100) / 12);
}
//Print details
void AmountCalculate::print() {
cout << "Peridic depositing amount : $" <<
periodicAmt << endl;
cout << "Compounding interest Rate : " <<
interest <<"%"<< endl;
cout << "Number of years depositted : " <<
year << endl;
cout << "Accumulated
Amount : $"
<< Calculate() << endl;
}
main.cpp
#include <iostream>
#include "AmountAccumulate.h"
using namespace std;
//Function protoytpe
void test();
int main()
{
test();
}
//test method
void test() {
double amt, ir;
int yr;
//Prompt for each values
cout << "Enter the periodic amount : ";
cin >> amt;
cout << "Enter interest rate : ";
cin >> ir;
cout << "Enter years : ";
cin >> yr;
//Create object
AmountCalculate calculator(amt, ir, yr);
calculator.print();
}
---------------------------------------------------------
Output
Enter the periodic amount : 500
Enter interest rate : 4.8
Enter years : 25
Peridic depositing amount : $500
Compounding interest Rate : 4.8%
Number of years depositted : 25
Accumulated Amount
: $289022
C++ Program help! Typically, everyone saves money periodically for retirement, buying a house, or for some...
You have accumulated some money for your retirement. You are going to withdraw $80,868 every year at the end of the year for the next 20 years. How much money have you accumulated for your retirement? Your account pays you 7.47 percent per year, compounded annually. To answer this question, you have to find the present value of these cash flows.
You have accumulated some money for your retirement. You are going to withdraw $73,170 every year at the end of the year for the next 29 years. How much money have you accumulated for your retirement? Your account pays you 13.01 percent per year, compounded annually. To answer this question, you have to find the present value of these cash flows.
Andrea, a self-employed individual, wishes to accumulate a retirement fund of $350,000. How much should she deposit each month into her retirement account, which pays interest at a rate of 2.5%/year compounded monthly, to reach her goal upon retirement 35 years from now? (Round your answer to the nearest cent.)
Andrea, a self-employed individual, wishes to accumulate a retirement fund of $650,000. How much should she deposit each month into her retirement account, which pays interest at a rate of 2.5%/year compounded monthly, to reach her goal upon retirement 25 years from now? (Round your answer to the nearest cent.) $
Pat has a Keogh retirement plan (this type of plan is tax-deferred until money is withdrawn). If deposits of $10,000 are made each year into an account paying 8% compounded annually, how much will be in the account after 23 years? What will be the total amount of interest earned? The amount in the account after 2 years is $ (round to the nearest cent, as needed). The amount of interest earned is s (round to the nearest cent, as...
You have accumulated some money for your retirement. You are going to withdraw $71,164 every year at the end of the year for the next 17 years. How much money have you accumulated for your retirement? Your account pays you 11.41 percent per year, compounded annually. To answer this question, you have to find the present value of these cash flows. Round the answer to two decimal places.
You have accumulated some money for your retirement. You are going to withdraw $65,720 every year at the end of the year for the next 16 years. How much money have you accumulated for your retirement? Your account pays you 4.84 percent per year, compounded annually. To answer this question, you have to find the present value of these cash flows. Round the answer to two decimal places.
You are planning to make monthly deposits of $490 into a retirement account that pays 10 percent interest compounded monthly. If your first deposit will be made one month from now, how large will your retirement account be in 30 years? b) In the previous problem, suppose you make $3,600 annual deposits into the same
You have accumulated some money for your retirement. You are going to withdraw $61,496 every year at the beginning of the year for the next 21 years starting from today. How much money have you accumulated for your retirement? Your account pays you 4.81 percent per year, compounded annually. To answer this question, you have to find the present value of these cash flows. Round the answer to two decimal places.
You have accumulated some money for your retirement. You are going to withdraw $65,548 every year at the end of the year for the next 20 years. How much money have you accumulated for your retirement? Your account pays you 18.61 percent per year, compounded annually. To answer this question, you have to find the present value of these cash flows. Round the answer to two decimal places.