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

You will write a C++ program that calculates and prints a table of savings accou

ID: 663916 • Letter: Y

Question

You will write a C++ program that calculates and prints a table of savings account balances per year up to a maximum given number of years for three different types of compound values (daily, monthly, annually).  Each row will have a year (starting at 1) and three balances for each compound value.  Use columns of size 12 using the setw() function.   Set precision to 2 to get 2 digits after the decimal point.  Also, remember to use 'fixed' and 'showpoint'.  

    The formula to find the balance is given as:          balance=principal?( 1+ rate n ) ^ ( years?n)

where:

• balance:  the amount of balance

• years: the number of years since the account was opened.            (starting from 1 year up to given number of years).

• principal:  the initial amount added to the savings. Let's assume no other deposits have been made.

• rate:  The annual interest rate (as a ratio).

• n:  The compound value which is the number of times during the year the interest is added to the balance.  For the three compound values we are interested in: • n = 365 for daily. • n = 12   for monthly. • n = 1     for annually.

You will start by asking the user for a series of values:    name, principal, annual rate and how many years of balances.  You should check to make sure the user doesn't enter anything that doesn't make sense, such as negative numbers, etc.  Limit the number of years to the range of 1 to 20,  principal from 1 to 10000 and annual rate from 1 to 100 percent.  If the user enters a number outside the range, prompt them to re­enter until they give you a value within the range.  Remember to convert the percentage to a ratio by dividing by 100.   You don't need to check for type of input, assume that the user will enter a number when a number is called for and so on.

Some Hints on Implementation     You should use either a for loop or while to print out each row in the table (the header needs to be printed before entering the loop).  To raise a value to a power, you will need to use the pow() function from the  library. You also need to use the io manipulator functions which require you to include the  library along with the  library.

EXAMPLE RUN (User input is in red) SAVINGS CALCULATOR = What is your name? Jerry Well, Jerry, I am going to ask you some questions. 1. How much money do you want to initially put into savings? 8000 2. What is the annual interest rate as a percentage? 12 3. How many years do you want to print out? 14 YEAR Daily Monthy Annuallv 1 2 9019.80 10169.59 11465.96 12927.58 14575.51 16433.52 18528.38 20890.28 23553.26 26555.70 29940.87 33757.58 38060.81 42912.60 9014.60 10157.88 11446.15 12897.81 14533.57 16376.79 18453.78 20794.18 23431.41 26403.10 29751.67 33524.92 37776.72 42567.76 8960.00 10035.20 11239.42 12588.15 14098.73 15790.58 17685.45 19807.71 22184.63 24846.79 27828.40 31167.81 34907.94 39096.90 5 6 10 12 13 14

Explanation / Answer

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double CI, P, r, x, n;
int t;
while(1)
{
cout <<"Enter the principal: ";
cin >> P;
if ((P>100000) || (P<1))
continue;
cout << " Enter rate: ";
cin >> r;
if ((r>100) || (r<1))
continue;
cout << " Enter time: ";
cin >> t;
if ((t>20) || (t<1))
continue;
break;
};
cin>>n;
x = P*pow((1.0+r/100.0*n), t*n);
CI = x - P;
cout << " The Compound Interest is: " << CI << endl;
return 0;
}

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