Exercise bank earnings

Bài tập gửi ngân hàng and Bank interest Exercises are very practical, but also the ability Thinking programming very high. This article we are going to learn some lessons about it.

Threads: One savers no limit to the amount a period at an interest rate 0.3% every month. Asked after n months, that person will withdraw all of the money is how nhie? Know that with the savings, the interest is not a term of community in the capital each month.

Threads quite clear, you just note one thing is the interest is added to capital. Therefore the next month, the number of our capital increasing. VD our original posts 100 million, six months 1 it is our money 100 + 100 * 0.3% = 100.3 million (100 million 300 short). This amount will be the root of the following month. So every month 2 we have 100.3 + 100.3 * 0.3% = X (you self, its slightly lazy ^^ ).

And so the following month accrue to. From there we see the following amounts to calculate monthly expenditure n then we need to use a loop is finished.

#include <stdio.h>

int main()
{
	float a;
	int n, i;

	printf("Enter money start give bank: ");
	scanf("%f", &a);

	printf("Enter time (month) you want get money: ");
	scanf("%d", &n);

	for(i = 0; i < n; i++) 
	{
		a = a + a * 0.3 / 100;
	}

	printf("Your money after %d month is %.5f\n", n, a);

	return 0;
}

Very simple is not it. If you run the program and enter 100000000 (100 million) then after 6 month, we have 101813552 (101 million and more 800 short) @@ rates too low =)).

Threads: One savers no limit to the amount a period at an interest rate 0.3% every month. Ask after how many months, he withdrew the money will be credited at least B contract? Know that with the savings, the interest is not a term of community in the capital each month.

Seemingly well as lessons on, however this time we again asked to get the money. VD initially sent 100 million must calculate to achieve 150 How many millions you lost time bank? ^^.

Because of the time we do not know so we can not use loop to calculate. How to calculate monthly payments are the same, will not know in advance how many times repeat, that repeat many times that we have to find. Do vậy hãy nghĩ đến cách dùng vòng lặp while. Trong khi tiền chưa đủ thì cứ gửi ngân hàng thôi.

#include <stdio.h>

int main()
{
	float a, b;
	int n = 0;

	printf("Enter money start give bank: ");
	scanf("%f", &a);

	printf("Enter money you want: ");
	scanf("%f", &b);

	while(a < b) 
	{
		a = a + a * 0.3 / 100;
		n++;
	}

	printf("After %d month, you can get money\n", n);

	return 0;
}

Pretty simple. Hãy chạy thử nhé. Nếu bạn gửi 100 triệu thì sau 136 month (hơn 11 year) bạn mới thu được hơn 150 million. ^^. Quá lâu. Do vậy kinh nghiệm là không nên gửi ngân hàng, nếu có tiền hãy đầu tư vào kinh doanh hoặc nhiều quá thì gửi mình bớt, mình giữ hộ 😉