当前位置:网站首页>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>
运行结果:
边栏推荐
- Talk about Domain Driven Design
- From 5 seconds to 1 second, the system flies
- VNC Viewer方式的远程连接树莓派
- Mobile security tools -jad
- Memory barrier store buffer, invalid queue
- JDBC参数化查询示例
- Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
- JDBC读取Mysql数据列表
- 在线文本数字识别列表求和工具
- Vs how to configure opencv? 2022vs configuration opencv details (multiple pictures)
猜你喜欢

正斜杠反斜杠的由来

Rust Async: smol源码分析-Executor篇

(resolved) NPM suddenly reports an error cannot find module 'd:\program files\nodejs\node_ modules\npm\bin\npm-cli. js‘

(已解决) npm突然报错 Cannot find module ‘D:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js‘

进程终止(你真的学会递归了吗?考验你的递归基础)

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

Interviewer: please introduce cache penetration, cache null value, cache avalanche and cache breakdown, which are easy to understand

From 5 seconds to 1 second, the system flies

OpenCV怎么下载?OpenCV下载后怎么配置?

Xiaomi Interviewer: let's talk about the proficient Registration Center for three days and three nights
随机推荐
Origin of forward slash and backslash
js中判断奇偶的函数,求圆面积的函数
MySQL
PostgreSQL encounters permission denied in Windows system
移动安全工具-jad
Construction of defense system for attack and defense exercises part II common strategies for responding to attacks
Websocket database listening
Custom palette for ggplot2
pytorch Default process group is not initialized
Idea method template
Get the query parameter in the address URL specify the parameter method
JDBC操作Mysql示例
Machine learning
R language analyzing wine data
Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
DMU software syntax highlighting VIM setting -- Learning Notes 6
一个人管理1000台服务器?这款自动化运维工具一定要掌握
Classical cryptosystem -- substitution and replacement
Solve the problem of win10 wsl2 IP change
在线文本数字识别列表求和工具