The approach I would take is write a function to calculate deductions for every month. To do it right, you will also need to determine how many days each month has. This is fairly simple except for the wrinkle that leap years cause. You can find this code on the internet so I might as well show you how this could look.
bool IsLeapYear( int year )
{
if( year % 4 )
return false; if( year % 100 )
return true; if( year % 400 )
return false;
return true; }
int GetDaysInMonth( int year , int month )
{
const int monthsInYear = 12;
const int daysInMonth[ monthsInYear ] =
{
31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 };
if( ( month < 0 ) || ( month >= monthsInYear ) )
return 0;
bool isLeap = IsLeapYear( year );
int number = daysInMonth[ month ];
if( isLeap && ( month == 1 ) )
++number; return number;
}
Given this, for a given year you determine how many days are in each month.
The next thing you need to do is implement an account manager. It needs to have a starting date and an initial balance. Let's say you start at January 1st of this year and the account has $200 in it. Write a function to determine the end-of-month balance of the account. You will find that last January had 31 days in it by calling the function listed. Next determine how much the monthly income was. Then apply the deduction rules stated and you will have the balance. Make a loop and you should be able to do this for every month following of the entire year or any time duration you care to examine.
If I were you, I would also make one function to determine the income and another to determine the deductions for a given month and year. You aren't likely to find all of this on google and it is for the best that you don't. You are supposed to learn something and lifting a bunch of code from somewhere else does not teach one very much. This day-date stuff I showed you can be found many places and is this just one of many different ways it can be done.