if=============================
var score = prompt("请输入小明的期末成绩")
score = parseInt(score)
if (score==100) {
alert('奖励一辆BMW');
}
else if ( score>=80 && score<=99) {
alert('奖励一辆iPhone15s');
}
else if ( score>=60 && score<80) {
alert('奖励一本参考书');
}
else{
alert('继续努力');
}
var height = prompt('请输入身高:')
var money = prompt('请输入money:')
var shuai = prompt('请输入shuai:')
if(height>=180 && money>=100000000 && shuai>=500){
alert('嫁给他');
}
else if(height>=180 || money>=100000000 || shuai>=500){
alert('嫁吧,比上不足,比下有余');
}
else{
alert('不嫁');
}
var num1 = prompt()
var num2 = prompt()
var num3 = prompt()
num1 = parseInt(num1)
num2 = parseInt(num2)
num3 = parseInt(num3)
var temp;
if (num1>num2) {
temp =num1;
num1 = num2;
num2 = temp
}
if (num1>num3) {
temp = num1;
num1 = num3;
num3 = temp
}
if (num2>num3) {
temp = num2;
num2 = num3;
num3 = temp
}
alert('num1 num2 num3')
switch==============================
var score = prompt('请输入分数:');
score = parseInt(score);
switch(true){
case (score>=60&&score<=100):
alert('合格');
break
case(score>=0&&score<60):
alert('不合格');
break
default:
alert('请重新输入');
break
}
var today = prompt('请输入参数:');
today = parseInt(today);
switch(today){
case 1:
alert('星期一');
break;//结束整个switch语句
case 2:
alert('星期二');
break;
case 3:
alert('星期三');
break;
case 4:
alert('星期四');
break;
case 5:
alert('星期五');
break;
case 6:
alter('星期六');
break;
case 7:
alert('星期日');
break;
default:
alert('非法参数');
break;//最后一个default可以不写break,但建议写上
}
while=============================
var i = 1000;
var num =0;
while(i<=5000){
i +=i * 0.05;
num++;
}
alert(num);
while(true){
var score = prompt('请输入分数');
if (score>=0 && score<=100) {
alert('输入合法')
break
}else{
alert('输入不合法')
}
}
for===============================
var sum = 0;
for(var i = 1; i <= 100; i++){
if(i % 2!= 0){
sum += i;
}
}
document.write(sum+"
");
var sum = 0;
var alist=[];
for(var i = 1; i <= 100; i++){
if(i % 7 == 0){
alist.push(i);
sum+=i;
}
}
document.write(sum+"
");
document.write(alist.length);
for(var i = 100; i < 1000; i++){
if (Math.pow(parseInt(i/100),3)+Math.pow((parseInt(i/10)%10),3)+Math.pow((i%10),3) == i){
alert(i)
}
}
var num = prompt("请输入一个数");
var count = 1;
for (; ;) {
if(num==""){
alert("不能为空")
break
}
if(num/parseInt(num)!=1){
alert("请不要输入小数")
break
}
if(num<0){
alert("请输入正整数")
break
}
for (var i = 2; i <= parseInt(num / 2); i++) {
if (num % i == 0) {
count = 0;
break
}
}
if (num >= 2 && count == 1) {
alert(parseInt(num) + "是质数")
} else {
alert(num + "不是质数")
}
break
}
step();
function step(){
for(i=1;i<=9;i++){
for(j=1;j<=i;j++){
document.write(i+"x"+j+"="+i*j +" ");
}document.write("
")
}
}
var flag=0;
for(var j=1;j<101;j++){
for(var i=2;i
计算器
计算器
计算器