| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 520 人关注过本帖
标题:js的一道习题求教
取消只看楼主 加入收藏
zhineng28
Rank: 1
等 级:新手上路
帖 子:58
专家分:0
注 册:2005-3-11
收藏
 问题点数:0 回复次数:2 
js的一道习题求教

下面是我在课本上的一到习题!根据学生的等级评A B C D级。
<script language="javascript">
document.write("<font size='+1'>");
while(true){
var score=eval(prompt("Please input the score:",""));
if (score<0 || score>100){
document.writeln("The score should be between 0 to 100!");
continue;
}
if(score>89 && score<101){
document.writeln("The degree is: A");
}
else if (score>79 && score<90){
document.writeln("The degree is: B");
}
else if(score>69 && score<80){
document.writeln("The degree is: c");
}
else if(score>59 && score<70);{
document.writeln("The degree is: D");
}
else {
document.writeln("It is bad!");
}
answer = prompt("Do you want to input another student?","");
if(answer !="y"){
break;
}
}
document.write("终于可以休息了...<br>");
</script>

我仔细的检查过上面的代码好几次了,都没发现什么错误啊!但是浏览的时候就是空白页,什么提示框都没有,真奇怪,请指教吧!呵呵

搜索更多相关主题的帖子: 习题 
2005-11-10 08:41
zhineng28
Rank: 1
等 级:新手上路
帖 子:58
专家分:0
注 册:2005-3-11
收藏
得分:0 
呵呵,就是多了个;,真是查死人啦!

2005-11-10 14:34
zhineng28
Rank: 1
等 级:新手上路
帖 子:58
专家分:0
注 册:2005-3-11
收藏
得分:0 

呵呵,我看过浏览器的左下角,是没有显示网页有错误的.知识显示"完毕".
上面的代码是多了个";"的问题.
经过高人指点我帮上面的代码改了一下,但是看不到效果,请指教吧!呵呵
<script language="javascript">
var score=eval(prompt("Please input the score:",""))
switch(score){
case score>89 && score<101:
document.writeln("The degree is: A");
break;
case score>79 && score<90:
document.writeln("The degree is: B");
break;
case score>69 && score<80:
document.writeln("The degree is: C");
break;
case score>59 && score<70:
document.writeln("The degree is: D");
break;
case score<59:
document.writeln("The degree is: Bad");
break;
}
answer = prompt("Do you want to input another student?","");
if(answer !="y"){
break;
}

</script>


2005-11-11 16:55
快速回复:js的一道习题求教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011860 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved