当前位置:网站首页>js用while循环计算假如投资多年的利率为5%,试求从1000块增长到5000块,需要花费多少年
js用while循环计算假如投资多年的利率为5%,试求从1000块增长到5000块,需要花费多少年
2022-06-27 07:20:00 【I am the sun?】
代码如下:
<!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>假如投资多年的利率为5%,试求从1000块增长到5000块,需要花费多少年</title>
<script type="text/javascript">
var money = 1000;
var year = 0;
while(money <= 5000){
money = money +(money*0.05);
year++;
console.log("第" + year + "年,有" + money + "元"+"<br />");
}
</script>
</head>
<body>
</body>
</html>
运行结果如下:
或者也可以这样:
代码:
<!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>假如投资多年的利率为5%,试求从1000块增长到5000块,需要花费多少年</title>
<script type="text/javascript">
var money = 1000;
var year = 0;
while(money <= 5000){
money = money +(money*0.05);
year++;
}
console.log("第" + year + "年,有" + money + "元"+"<br />");
</script>
</head>
<body>
</body>
</html>
运行结果:
边栏推荐
- R language consumption behavior statistics based on association rules and cluster analysis
- Speech signal processing - concept (I): time spectrum (horizontal axis: time; vertical axis: amplitude), spectrum (horizontal axis: frequency; vertical axis: amplitude) -- Fourier transform -- > time
- Interviewer: do you have any plan to request a lot of data that does not exist in redis to destroy the database?
- Cookie加密6
- Speech signal feature extraction process: input speech signal - framing, pre emphasis, windowing, fft- > STFT spectrum (including amplitude and phase) - square the complex number - > amplitude spectru
- What is the difference between volatile and synchronized?
- volatile 和 synchronized 到底啥区别?
- File 与 MultipartFile概述
- Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
- One person manages 1000 servers? This automatic operation and maintenance tool must be mastered
猜你喜欢

Yarn create vite reports an error 'd:\program' which is neither an internal or external command nor a runnable program or batch file

Gérer 1000 serveurs par personne? Cet outil d'automatisation o & M doit être maîtrisé

2、项目使用的QT组件

Win10 remote connection to ECS

Winow10 installation nexus nexus-3.20.1-01

磁选机是什么?

mssql如何使用语句导出并删除多表数据

Interviewer: do you have any plan to request a lot of data that does not exist in redis to destroy the database?
![[Software Engineering] software engineering review outline of Shandong University](/img/38/2c783df56b50dee3bbb908f6f3e70e.png)
[Software Engineering] software engineering review outline of Shandong University
![[graduation season] graduation is the new beginning of your life journey. Are you ready](/img/4e/aa763455da974d9576a31568fc6625.jpg)
[graduation season] graduation is the new beginning of your life journey. Are you ready
随机推荐
在线文本数字识别列表求和工具
专业四第二周自测
C# 请问怎么在更新数据库时候调用line与rows
Speech signal feature extraction process: input speech signal - framing, pre emphasis, windowing, fft- > STFT spectrum (including amplitude and phase) - square the complex number - > amplitude spectru
Easyexcel: read Excel data into the list set
OpenCV怎么下载?OpenCV下载后怎么配置?
Write an example of goroutine and practice Chan at the same time
log4j:WARN No such property [zipPermission] in org.apache.log4j.RollingFileAppender.
语音信号处理-概念(四):傅里叶变换、短时傅里叶变换、小波变换
获取地址url中的query参数指定参数方法
JDBC参数化查询示例
进程终止(你真的学会递归了吗?考验你的递归基础)
How torch. gather works
Difference between boundvalueops and opsforvalue
File 与 MultipartFile概述
Winow10 installation nexus nexus-3.20.1-01
R 语言并行计算 spearman 相关系数,加快共现网络(co- occurrence network)构建速度
Construction of defense system for attack and defense exercises part II common strategies for responding to attacks
Centos7.9 install MySQL 5.7 and set startup
[openairinterface5g] rrcsetupcomplete for RRC NR resolution