while

2018-12-12  本文已影响0人  九妄_b2a1
利率
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>投资的年利率</title>
    <script type="text/javascript">
        var money = 1000;
        var count = 0;
        while(money < 5000){
            money *= 1.05;
            count++;
        }
        console.log("一共需要" + count + "年");
    </script>
</head>
<body>
    
</body>
</html>
成绩
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>成绩</title>
    <script type="text/javascript">
        while(true){
            var score = prompt("请输入小明的期末成绩(0-100):");
            if(score <= 100 && score >= 0){
                break;
            }
            alert('请输入有效的分数!!!');
        }
        if(score == 100){
            alert("宝马");
        }else if(score >= 80){
            alert("手机");
        }else if(score >= 60){
            alert("参考书");
        }else{
            alert("");
        }
    </script>
</head>
<body>
    
</body>
</html>
上一篇下一篇

猜你喜欢

热点阅读