gpt4 book ai didi

javascript - Javascript 数学中的奇怪结果?

转载 作者:行者123 更新时间:2023-11-30 09:05:48 26 4
gpt4 key购买 nike

我制作此表格是为了根据用户输入计算积分。

可能的最高分是 105,但给出的结果是 97。

要获得最高分,选择是:

  • 21-49
  • 博士或硕士,17 岁
  • 6.5+
  • 7.5+
  • 6.5+
  • 6.5+
  • 4 年或更长时间
  • 拥有硕士或博士学位并完成了至少 17 年的全日制学习
  • 是的,17 岁以后接受中等教育两年以上
  • 在加拿大全职工作至少一年

这是我的代码:

<html>
<head>
</head>
<body>
<form name="form">
<input name="pnt" type="hidden" value=" points">
<input name="rsn" type="hidden" value=" -not eligible">
<input name="rsy" type="hidden" value=" -eligible">
<label>Age</label>
<select name='g'>
<option value='' >Select One</option>
<option value='0' >Less than 17</option>
<option value='2' >17</option>
<option value='4' >18</option>
<option value='6' >19</option>
<option value='8' >20</option>
<option value='10' >21-49</option>
<option value='8' >50</option>
<option value='6' >51</option>
<option value='4' >52</option>
<option value='2' >53</option>
<option value='0' >54+</option>
</select>
<label>Education</label><select name='a'>
<option value='' selected='selected'>Select one</option>
<option value='0' >No High School</option>
<option value='5' >Secondary School</option>
<option value='12' >One Year Diploma, apprenticeship AND 12 years full time study</option>
<option value='15' >One Year Diploma, apprenticeship AND 13 years full time study</option>
<option value='15' >Bachelors Degree from University AND 13 years full time study</option>
<option value='20' >2 year diploma AND 14 years full time study</option>
<option value='20' >2 year bachelor&#039;s degree from university AND 14 years full time study</option>
<option value='22' >3 year diploma AND 15 years full time study</option>
<option value='22' >2 bachelor degrees from university and 15 years full time study</option>
<option value='25' >PhD or Masters &amp; 17 years full time study</option>
</select>
<h3><strong>Primary Language</strong></h3>
<label>Speaking</label>
<select name="c">
<option value='' >Select One</option>
<option value='4' >6.5+</option>
<option value='2' >5.5 – 6.0</option>
<option value='1' >4.0 – 5.0</option>
<option value='0' >Less than 4.0</option>
</select>
<label>Listening</label>
<select name="d">
<option value='' selected='selected'>Select One</option>
<option value='4' >7.5+</option>
<option value='2' >5.5 – 7.0</option>
<option value='1' >4.5 – 5.0</option>
<option value='0' >Less than 4.5</option>
</select>
<label>Reading</label>
<select name="e">
<option value='' >Select One</option>
<option value='4' >6.5+</option>
<option value='2' >5.0 – 6.0</option>
<option value='1' >3.5 – 4.5</option>
<option value='0' >Less than 3.5</option>
</select>
<label>Writing</label>
<select name='f'>
<option value='' >Select One</option>
<option value='4' >6.5+</option>
<option value='2' >5.5 – 6.0</option>
<option value='1' >4.0 – 5.0</option>
<option value='0' >Less than 4.0</option>
</select>
<h3><strong>Work</strong></h3>
<label>Work Experience</label>
<select name="b">
<option value=''>Select One</option>
<option value='0' >Less than 1 year</option>
<option value='15' >1 Year</option>
<option value='17' >2 Years</option>
<option value='19' >3 Years</option>
<option value='21' >4 Years or more</option>
</select>

<label>Arranged Employment</label>
<select name="l">
<option value=''>Select One</option>
<option value='10'>Yes</option>
<option value='0'>No</option>
</select>

<h3><strong>Adaptability</strong></h3>
<label>Spouse&#039;s Education</label>
<select name="h">
<option value='' >Select One</option>
<option value='0' >Secondary School</option>
<option value='3' >One Year Diploma, apprenticeship AND 12 years full time study</option>
<option value='3' >Bachelors Degree from University AND 13 years full time study</option>
<option value='4' >A two-year diploma, trade certificate or apprenticeship or university degree at the bachelor's level and completed at least 14 years of full-time or full-time equivalent studies</option>
<option value='4' >A three-year diploma, trade certificate or apprenticeship (not university) and completed at least 15 years of full-time or full-time equivalent studies</option>
<option value='4' >Two or more university degrees at the bachelor's level and completed at least 15 years of full-time or full-time equivalent studies</option>
<option value='5' >A master's or Ph.D. and completed at least 17 years of full-time or full-time equivalent studies</option>
<option value='0' >No Education</option>
</select>

<label>Applicant OR Spouse has studied in Canada</label>
<select name='i'>
<option value='5'>Yes, more than two years post secondary after the age of 17.</option>
<option value='0'>Yes, but for less than two years</option>
<option value='0'>No</option>
</select>
<label>Applicant OR Spouse has worked in Canada</label>
<select name="j">
<option value='' selected='selected'>Select One </option>
<option value='5'>Worked full-time in Canada for at least one year</option>
<option value='0'>Yes, but for less than 1 year</option>
<option value='0'>No</option>
</select>
<label>Applicant or Spouse has Family in Canada</label>
<select name="k">
<option value='' selected='selected'>Select One</option>
<option value='5'>Yes</option>
<option value='0'>No</option>
</select>
<INPUT NAME="calc" VALUE="Calculate" TYPE="button" onClick="compute(this.form)">
<input name="rslt" type="text" style="font-size: 50px" value="" size="20" readonly="readonly">
</form>
<script language="JavaScript">
<!-- hide this script from old browsers
function compute(form)
{
var a = parseInt(form.a.value);
var b = parseInt(form.b.value);
var c = parseInt(form.c.value);
var d = parseInt(form.d.value);
var e = parseInt(form.e.value);
var f = parseInt(form.f.value);
var g = parseInt(form.g.value);
var h = parseInt(form.h.value);
var i = parseInt(form.i.value);
var j = parseInt(form.j.value);
var k = parseInt(form.k.value);
var l = parseInt(form.l.value);
f = (a+b+c+d+e+f+g+h+j+k+l);

form.rslt.value = f;
}

// done hiding from old browsers -->
</script>
</body>
</html>

最佳答案

这一行少了“i”

f = (a+b+c+d+e+f+g+h+j+k+l);

(另外,最大值对我来说似乎是 102)

关于javascript - Javascript 数学中的奇怪结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5131516/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com