Money Calculator project in C++ Source Code

we are going to discuss this program

source code is below-:

What we did here was, we followed the following steps-:

We are needed to find the average monthly income, so we made array of income in 12 months ..say it is X[12]…and then we took the input of array elements from 1 to 12 i .e from month january to month december.

Now, we want to find the average monthly income of that person,and we know that

avg=sum/total n

so, we need to find sum before finding average

Hence,for that, we calculated sum as sum=sum+a[i]..addition of array with a simple variable is possible here! some one may get confused here…here a[i] is not the whole array, it will depend on the value of i,what a[i] is showing to us.

Now, we want to display the income of that person.

We don’t want our income to be displayed with 8 decimal figures, do we?

Remember that keeping many decimal values is necessary where even a small change of order of micro or nano, can have a great effect, and yes there are technologies which get affected by these amount of changes, let’s not get diverted towards that.

So, for showing only 2 decimal values we did “%.2f”-i.e we used the format specifiers here.

Hence done.

Though this may not seem as a good project like the one I did in past, but these small projects will also help you to learn data structures aand algorithms as well as programming.

They will also be suitable for programming contests also.


Be the first to comment

Leave a Reply

Your email address will not be published.