当前位置:网站首页>JS uses the while cycle to calculate how many years it will take to grow from 1000 yuan to 5000 yuan if the interest rate for many years of investment is 5%

JS uses the while cycle to calculate how many years it will take to grow from 1000 yuan to 5000 yuan if the interest rate for many years of investment is 5%

2022-06-27 07:35:00 I am the sun?

The code is as follows :

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title> If the interest rate for many years of investment is 5%, Try to follow 1000 The block grows to 5000 block , How many years will it take </title>
	<script type="text/javascript">
		var money = 1000;
		var year = 0;
		while(money <= 5000){
			money = money +(money*0.05);
			year++;
			console.log(" The first " + year + " year , Yes " + money + " element "+"<br />");
		}
	</script>
</head>
<body>
	
</body>
</html>

The operation results are as follows :
 Insert picture description here
Or it could be :
Code :

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title> If the interest rate for many years of investment is 5%, Try to follow 1000 The block grows to 5000 block , How many years will it take </title>
	<script type="text/javascript">
		var money = 1000;
		var year = 0;
		while(money <= 5000){
			money = money +(money*0.05);
			year++;
		}
		console.log(" The first " + year + " year , Yes " + money + " element "+"<br />");
	</script>
</head>
<body>
	
</body>
</html>

Running results :
 Insert picture description here

原网站

版权声明
本文为[I am the sun?]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270720100071.html