```/*********************************************
More finance

Write a program that reads in a number of
years from the user, and prints the balance
at the end of each year of an account that
starts with \$100 and accrues 7.5% interst,
comounded annually.  For Example:

How many years? 5
Balance after 1st year is 107.5
Balance after 2nd year is 115.562
Balance after 3rd year is 124.23
Balance after 4th year is 133.547
Balance after 5th year is 143.563

The trick is that you need the right adective
endings on the numbers!
*********************************************/
#include <iostream>
#include <string>
using namespace std;

string ending(int);

/*********************************************
** main() function
*********************************************/
int main()
{
double B = 100.0;
double r = 7.5;

int Y;
cout << "How many years? ";
cin >> Y;

for(int i = 0; i < Y; i++)
{
B = B*(1 + r/100);
cout << "Balance after " << (i+1)
<< ending(i+1)
<< " year is " << B << endl;
}

return 0;
}

/*********************************************
** Finds the appropriate ending for writing
** out a number in its adjective form.
*********************************************/
string ending(int n)
{
string s;
if (n % 100 > 10 && n % 100 < 20)
s = "th";
else if (n % 10 == 1)
s = "st";
else if (n % 10 == 2)
s = "nd";
else if (n % 10 == 3)
s = "rd";
else
s = "th";

return s;
}

```