1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>if練習(xí)1</title>
<script type="text/javascript">
/*
* 從鍵盤輸入小明的期末成績:
* 當(dāng)成績?yōu)?00時(shí)罕偎,'獎(jiǎng)勵(lì)100元'
* 當(dāng)成績?yōu)閇80-99]時(shí)拓轻,'獎(jiǎng)勵(lì)60元'
* 當(dāng)成績?yōu)閇60-80]時(shí)痰哨,'獎(jiǎng)勵(lì)30元'
* 其他時(shí)行剂,什么獎(jiǎng)勵(lì)也沒有
*/
var score = prompt("請輸入小明的期末成績")
if (score==100) {
alert("獎(jiǎng)勵(lì)100元")
}
else if(score>79){
alert("獎(jiǎng)勵(lì)60元")
}
else if(score>59){
alert("獎(jiǎng)勵(lì)30元")
}
else{
alert("弟弟")
}
</script>
</head>
<body>
</body>
<html>
2
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>if練習(xí)2</title>
<script type="text/javascript">
/*
* 大家都知道航徙,男大當(dāng)婚处面,女大當(dāng)嫁厂置。那么女方家長要嫁女兒,當(dāng)然要提出一定的條件:
* 高:185cm以上; 富:1200萬以上; 帥:100以上;
* 如果這三個(gè)條件同時(shí)滿足魂角,則:'我一定要嫁給他'
* 如果三個(gè)條件有為真的情況昵济,則:'嫁吧,比上不足野揪,比下有余访忿。'
* 如果三個(gè)條件都不滿足,則:'不嫁斯稳!'
*/
var height = prompt("請輸入身高")
var money = prompt("請輸入財(cái)富,單位為萬")
var smart = prompt("請輸入顏值")
if (height>=185&&money>=1200&&smart>=100) {
alert("我一定要嫁給他")
}
else if (height>=185||money>=1200||smart>=100) {
alert("嫁吧海铆,比上不足,比下有余挣惰。")
}
else {
alert("不嫁卧斟!")
}
</script>
</head>
<body>
</body>
<html>
3
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>if練習(xí)3</title>
<script type="text/javascript">
/*
* 編寫程序,由鍵盤輸入三個(gè)整數(shù)分別存入變量num1憎茂、num2珍语、num3,
* 對他們進(jìn)行排序竖幔,并且從小到大輸出板乙。
*/
var num1 = prompt("請輸入第一個(gè)數(shù):");
? ? ? ? ? ? var num2 = prompt("請輸入第二個(gè)數(shù):");
? ? ? ? ? ? var num3 = prompt("請輸入第三個(gè)數(shù):");
? ? ? ? ? ? if(num1 < num2 && num1 < num3){?
? ? ? ? ? ? ? ? if(num2 < num3){
? ? ? ? ? ? ? ? ? ? alert(num1 +","+num2 + ","+num3);
? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? alert(num1 +","+num3 + ","+num2);
? ? ? ? ? ? ? ? }? ?
? ? ? ? ? ? }else if(num2 < num1 && num2 < num3){
? ? ? ? ? ? ? ? if(num1 < num3){
? ? ? ? ? ? ? ? ? ? alert(num2 +","+num1 + ","+num3);
? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? alert(num2 +","+num3 + ","+num1);
? ? ? ? ? ? ? ? }?
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? if(num1 < num2){
? ? ? ? ? ? ? ? ? ? alert(num3 +","+num1 + ","+num2);
? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? alert(num3 +","+num2 + ","+num1);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
</script>
</head>
<body>
</body>
<html>
4
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>switch練習(xí)1</title>
<script type="text/javascript">
/*
* 對于成績大于等于60分的,輸出'合格'拳氢。低于60分的募逞,輸出'不合格'
*/
var score = Number(prompt("請輸入您的分?jǐn)?shù)"))
if (score>=60) {
var score_ =true;
}else{
var score_ =false;
}
switch(score_){
case true:
alert("合格")
break
default:
alert("不合格")
}
</script>
<body>
</body>
<html>
5
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>switch練習(xí)2</title>
<script type="text/javascript">
/*
* 從鍵盤接收整數(shù)參數(shù),如果該數(shù)為1-7馋评,打印對應(yīng)的星期放接,否則打印非法參數(shù)。
*/
var i = prompt("請輸入1~7的整數(shù)")
i = parseInt(i)
switch(i)
{
case 1:
alert("星期一")
break
case 2:
alert("星期二")
break
case 3:
alert("星期三")
break
case 4:
alert("星期四")
break
case 5:
alert("星期五")
break
case 6:
alert("星期六")
break
case 7:
alert("星期日")
break
default:
alert("非法參數(shù)")
}
</script>
<body>
</body>
<html>
6
<!DOCTYPE html>
<html>
<head>
<title>while練習(xí)一</title>
<script type="text/javascript">
var i =0
var money=1000
while(true){
money=money+money*0.05
i++
if (money>5000) {
alert(i)
break
}
}
</script>
</head>
<body>
</body>
<html>
7
<!DOCTYPE html>
<html>
<head>
<title>while練習(xí)二</title>
<script type="text/javascript">
while(true){
var i = 0
var score = prompt("請輸入分?jǐn)?shù)")
if (score<=0||score>100) {
alert("您輸入的分?jǐn)?shù)有誤栗恩,請重新輸入")
continue
}
else if(score==100){
alert("獎(jiǎng)勵(lì)100元")
}
else if(score>=80){
alert("獎(jiǎng)勵(lì)70元")
}
else if(score>=60){
alert("獎(jiǎng)勵(lì)30元")
}
else{
alert("弟弟")
}
}
</script>
</head>
<body>
</body>
<html>
8
<!DOCTYPE html>
<html>
<head>
<title>for練習(xí)一</title>
<script type="text/javascript">
var j = 0
for (var i = 0; i < 100; i++) {
if (i % 2 != 0) {
j=j+i
}
}
alert(j)
</script>
</head>
<body>
</body>
<html>
9
<!DOCTYPE html>
<html>
<head>
<title>for練習(xí)二</title>
<script type="text/javascript">
var a = 0
var j = 0
for (var i = 0; i <= 100; i++) {
if (i % 7 == 0) {
a+=1;
j+=i;
}
}
alert("7的倍數(shù)個(gè)數(shù)有:"+a)
alert("總和為:"+j)
</script>
</head>
<body>
</body>
<html>
10
<!DOCTYPE html>
<html>
<head>
<title>for練習(xí)三</title>
<script type="text/javascript">
for(var i=1; i<999;i++){
var bai = parseInt(i/100);
var shi = parseInt(i%100/10);
var ge = parseInt(i%10)
if(bai**3+ shi**3 + ge**3 == i){
alert(i)
}
}
</script>
</head>
<body>
</body>
<html>