学分绩点计算编程java_方便我们计算学分绩点的JavaScript

基于目前我们学校教务处的管理系统, 依靠Javascript的帮忙, 我们可以很方便地计算成绩.

测试用HTML:

style="width: 100%; border-collapse: collapse;">

课程代码

课程名称

课程性质

成绩

补考成绩

重修成绩

学分

绩点

辅修标记

24109505

数据库系统实验

专业基础课

优秀

0.5

4.50

24100320

单片机原理及应用

专业基础选修课

78

2.0

2.80

24100915

UML

校选修课

63

1.5

1.30

24200510

数据库系统课程设计

设计(论文)

优秀

1.0

4.50

24203910

可编程序控制器与工业控制网络课程设计

设计(论文)

良好

1.0

3

JavaScript:

//一学年的平均学分绩点=该学年修全部课程的学分绩点之和÷所修课程的总学分(校选修不计算在内)

//学业成绩平均分=一学年平均学分绩点折合为百分制的得数

//考通过的课程,按实际成绩记分,并给予学分,但其绩点均为“0”。重修的课程在该年度中按不及格科目计算,绩点为0。

function Calculate() {

var table = document.getElementById("DataGrid1");

var totalMark = 0;

var failCount = 0;

var subjectCount = 0;

var totalRate = 0;

var totalRawRate = 0;

for(var i = 1; i < table.rows.length; i++) {

if(table.rows[i].cells[2].innerHTML == "校选修课") continue;

subjectCount++;

var mark = getMark(table.rows[i].cells[3].innerHTML);

if(mark < 60) {

failCount++;

}

totalMark += mark;

totalRate += getMark(table.rows[i].cells[7].innerHTML)

* getMark(table.rows[i].cells[6].innerHTML);

totalRawRate += getMark(table.rows[i].cells[6].innerHTML);

}

var resultRow = document.getElementById("resultRow");

if(!resultRow) {

resultRow = document.createElement("tr");

resultRow.id = "resultRow";

}

resultRow.innerHTML = "";

var results = ["总分:", totalMark, "平均分:", (totalMark/subjectCount).toFixed(3),

"平均学分绩点:", (totalRate/totalRawRate).toFixed(3), "不及格数:",failCount];

for(var i = 0; i < results.length; i++) {

var td = document.createElement("td");

td.innerHTML = results[i];

resultRow.appendChild(td);

}

table.lastChild.appendChild(resultRow);

}

function getMark(markStr) {

switch(markStr) {

case "优秀": return 95;

case "良好": return 85;

case "中等": return 75;

case "及格": return 65;

case "不及格":

case "" :

case " ": return 0;

default: return parseFloat(markStr);

}

}

Calculate();

2fa5135fbd256176fc7b0df4d33c0992.png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/441369.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【POJ - 2663】Tri Tiling (简单dp)

题干&#xff1a; In how many ways can you tile a 3xn rectangle with 2x1 dominoes? Here is a sample tiling of a 3x12 rectangle. Input Input consists of several test cases followed by a line containing -1. Each test case is a line containing an integer …

java 反射 代码_java反射机制学习代码

根据http://www.iteye.com/topic/137944文档进行学习代码如下:package reflectTest;import java.lang.reflect.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.*;class A{}class B extends A{}class C extends B{}class TestClass …

【POJ - 1556】The Doors (计算几何,线段相交)

题干&#xff1a; You are to find the length of the shortest path through a chamber containing obstructing walls. The chamber will always have sides at x 0, x 10, y 0, and y 10. The initial and final points of the path are always (0, 5) and (10, 5). Th…

java处理linux中的 m_Linux下处理BOM头和^M的简单方法

Linux在网络服务器、嵌入式设备的市场上占有较大份额&#xff0c;Microsoft Windows在桌面操作系统上占有较大的份额&#xff0c;因此有很多的人喜欢用Windows去控制操作Linux。既然用Windows去控制Linux&#xff0c;难免导致Windows系统上的产生的文件以某种途径传到了Linux系…

【POJ - 1696】Space Ant (凸包,最小极角,排序)

题干&#xff1a; The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y1999 and called it M11. It has only one eye on the left side of its head and just three feet al…

2019蓝桥杯Java决赛题答案_2019第十届蓝桥杯JavaB组省赛真题详解

目录题解待更新第一题&#xff1a;组队题目描述做为篮球队教练&#xff0c;你须要从如下名单中选出 1 号位至 5 号位各一名球员&#xff0c; 组成球队的首发阵容。每位球员担任 1 号位至 5 号位时的评分以下表所示。请你计算首发阵容 1 号位至 5 号位的评分之和最大多是多少&am…

【FZU - 1759】Super A^B mod C (数论,快速幂,快速乘,欧拉降幂,指数循环节,模板)

题干&#xff1a; Given A,B,C, You should quickly calculate the result of A^B mod C. (1<A,C<1000000000,1<B<10^1000000). Input There are multiply testcases. Each testcase, there is one line contains three integers A, B and C, separated by a si…

java map统计学生名单_Java含自己的总结:集合,学生,遍历,ArrayList,Set,Map,泛型,班级,发牌—诗书画唱...

声明一个ArrayList&#xff0c;存储一条学生信息&#xff0c;内容为 1 张三 22 男&#xff0c;将信息进行遍历出来package list;import java.util.ArrayList;import java.util.Iterator;public class student{public static void main(String[] args) {ArrayList jiHe…

【AtCoder - 4242 】To Infinity(思维)

题干&#xff1a; Problem Statement Mr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows: Each occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4becomes 4444, 5 b…

java面向对象编程集合边框_JAVA 面向对象 集合框架

1.Java集合框架提供了一套性能优良、使用方便的接口和类&#xff0c;它们位于java.util包中如果并不知道程序运行时会需要多少对象&#xff0c;或者需要 更复杂方式存储对象——可以使用Java集合框架2.java集合框架包括接口、具体类、算法接口&#xff1a;Collection&#xff1…

【HDU - 2072 】单词数(字符串读入技巧,sstream大法,水题,字符串读入格式)

题干&#xff1a; lily的好朋友xiaoou333最近很空&#xff0c;他想了一件没有什么意义的事情&#xff0c;就是统计一篇文章里不同单词的总数。下面你的任务是帮助xiaoou333解决这个问题。 Input 有多组数据&#xff0c;每组一行&#xff0c;每组就是一篇小文章。每篇小文章都…

java生成world文件_HelloWorld.java文件如何创建?

原创HelloWorld.java文件如何创建&#xff1f;编辑:小丸子 来源:PC下载网时间:2017-10-17 19:55:54相信各位刚接触JAVA的新人都希望尽快编写出自己的第一个程序,今天PC下载网小编和你一起学习HelloWorld程序1.首先我们先点击“开始”—然后是“所有程序”—在然后是“附件”—记…

【HDU - 1251 】统计难题(字典树,求拥有公共前缀的字符串数量)

题干&#xff1a; Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀). Input 输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是…

java 轮询请求接口_js调用轮询接口

##### 项目中遇到需要很多个需要轮询处理的接口&#xff0c;然后简单的封装了下&#xff0c;做个记录&#xff0c;以后用到类似的直接copy #####// polling-utils.js/*** descripting 轮询功能* param {String} type 请求类型* param {String} url 地址* param {Object} data 请…

【POJ - 2001 】Shortest Prefixes (字典树,查询重复前缀区间)

题干&#xff1a; A prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", "ca", "car", "carb", "carbo", and "carbon". Note t…

mysql use index用法_MySQL中USE INDEX 和 FORCE INDEX

问题在一次生产环境排查性能问题时, 发现有个请求在一些用户的数据量比较大的情况下, 最高耗时差不多要3s. 而且还是一个轮询的请求.原因在排查问题时, 定位到是执行某条SQL时在用户的数据比较大的情况下, SQL执行耗时要1.5s.mysql> SELECT count(1)-> FROM-> cc_sess…

【AtCoder - 4244 】AtCoder Express 2 (区间dp 或 暴力枚举,思维)

题干&#xff1a; In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east. A company called AtCoder Express possesses Mtrains, and the train i runs from City Li to City Ri (it is possible that L…

【HDU - 3068】最长回文(Manacher算法,马拉车算法求最长回文子串)

题干&#xff1a; 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度. 回文就是正反读都是一样的字符串,如aba, abba等 Input 输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c...y,z组成的字符串S 两组case之间由空行隔开(该空行不用…

java程序员面试需要英语吗_Java程序员和高级程序员面试30题(英语)

Java程序员和高级程序员面试30题(英语)* Q1. How could Java classes direct program messages to the system console, but error messages, say to a file?A. The class System has a variable out that represents the standard output, and the variable err that represe…

【HDU - 1867 】A + B for you again(KMP,next数组应用)

题干&#xff1a; Generally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two strings, such as “asdf” and “sdfg”, the result of the addition between them is “asdfg”, for “sdf” is …