Javascript 如何通过自动检测科目代码中的学时和分数中的分数来计算GPA

Javascript 如何通过自动检测科目代码中的学时和分数中的分数来计算GPA,javascript,html,Javascript,Html,我只需要为主题代码和标记创建两个文本框 主题代码如:AA3143和标记如:100 对于学分,它将自动检测科目代码的最后编号,例如:3 以下是分数、等级和分数: 80-100 (A=4), 65-79 (B=3), 50-64 (C=2), 35-49 (D=1), 0-34 (F=0) 分数将为学分乘以分数,例如:3*4=12 计算GPA总分除以总学时,例如:12/3=4 这是主题代码和标记自动检测的代码,但我不知道如何根据这段代码计算GPA if ($mark <= 100

我只需要为主题代码和标记创建两个文本框

主题代码如:AA3143和标记如:100

对于学分,它将自动检测科目代码的最后编号,例如:3

以下是分数、等级和分数:

80-100 (A=4),
65-79 (B=3),
50-64 (C=2),
35-49 (D=1),
0-34 (F=0)
分数将为学分乘以分数,例如:3*4=12

计算GPA总分除以总学时,例如:12/3=4

这是主题代码和标记自动检测的代码,但我不知道如何根据这段代码计算GPA

      if ($mark <= 100 && $mark >=80){
          $code = substr($code,8);
          $point = $code * 4;
      }
      else if ($mark <= 79 && $mark >=65){
          $code = substr($code,8);
          $point = $code * 3;
      }
      else if ($mark <= 64 && $mark >=50){
          $code = substr($code,8);
          $point = $code * 2;
      }
      else if ($mark <= 49 && $mark >=35){
          $code = substr($code,8);
          $point = $code * 1;
      }
      else{
          $code = substr($code,8);
          $point = $code * 0;
      }
if($mark=80){
$code=substr($code,8);
$point=$code*4;
}
否则,如果($mark=65){
$code=substr($code,8);
$point=$code*3;
}
否则,如果($mark=50){
$code=substr($code,8);
$point=$code*2;
}
否则,如果($mark=35){
$code=substr($code,8);
$point=$code*1;
}
否则{
$code=substr($code,8);
$point=$code*0;
}
以下是我已经编写的代码:


GPA计算器
GPA计算器