while

作者: 九妄_b2a1 | 来源:发表于2018-12-12 13:41 被阅读0次
    利率
    <!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>
    

    相关文章

      网友评论

          本文标题:while

          本文链接:https://www.haomeiwen.com/subject/cgwuhqtx.html