I have done part of this program so far. The Rule of 72 is used by bankers and politicians which states that if R% is the annual rate of inflation, then a fixed sum of money will decline in value by 50% in 72/R years
I need to prove that Rule of 72 is reasonable for inflation rates of from 1 to 25%
Code:
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
int main()
{
// Declare Variables
double years;
double rate;
double calculate;
int hold;
//formula = abs(log10)(.5)/(log10(1+rate));
// Prove Rule of 72
int r = rate;
for (r = 1; r < 26; r++)
{
int y = years;
for (y = 1; y < 73; y++)
{
years = years / 2;
}
calculate = abs(log10(.5))/(log10(1+rate));
// Print Results to screen
cout << " Depreciation Chart in years to Test Rule 0f 72 " << endl;
cout << "Rate of % Inflation " << setw(5) << "#years by Rule of 72 " << setw(5) << "Calculated # of years " << endl;
cout << r << setw(5) << years << setw(5) << calculate << endl;
break;
}
cin >> hold;
return 0;
}
This is my code so far. The formula is right because I looked it up in the internet. I have a problem printing to the output. I used a for loop and i want to start from 1 and increment it by 1 until it reaches 25 and i need it to print that and the years and calculated # of years.