saveSCore在JAVA什么意思_第一次个人编程作业/src/Score.java · jevendavid/personal - Gitee.com...

import com.sun.javafx.binding.StringFormatter;

import org.jsoup.Jsoup;

import org.jsoup.nodes.Document;

import org.jsoup.nodes.Element;

import org.jsoup.select.Elements;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.util.Properties;

import java.util.Scanner;

public class Score {

public static void main(String args[]) throws IOException {

Document all=input( "D:/htmlSave/all.html");

Document small=input("D:/htmlSave/small.html");

System.out.println(String.format("%.2f",Calculator(all)));

System.out.println(String.format("%.2f",Calculator(small)));

}

public static Document input(String Html) throws IOException {

//找到本地html文件并导入

File html = new File(Html);

Document doc = Jsoup.parse(html, "UTF-8");

return doc;

}

public static double Calculator(Document file1) throws IOException {

//初始化参数

int before=0;

int base=0;

int test=0;

int program=0;

int add=0;

Properties properties=new Properties();//导入配置文件

properties.load(new FileInputStream("src/total.properties"));

//导入配置文件中的参数

double t_before=Integer.parseInt(properties.getProperty("before"));

double t_base=Integer.parseInt(properties.getProperty("base"));

double t_test=Integer.parseInt(properties.getProperty("test"));

double f_program=Integer.parseInt(properties.getProperty("program"));

double f_add=Integer.parseInt(properties.getProperty("add"));

Elements element=file1.getElementsByAttributeValue("class","interaction-row");//筛选

if(file1!=null){

for(Element e:element){

if (e.child(1).child(0).toString().contains("课前自测")){

if (e.child(1).child(2).toString().contains("color:#8FC31F\"")){

Scanner scanner=new Scanner(e.child(1).child(2).children().get(0).children().get(10).text());

before+=scanner.nextInt();

}

}else if (e.child(1).child(0).toString().contains("课堂完成")){

if (e.child(1).child(2).toString().contains("已参与 ")){

Scanner scanner=new Scanner(e.child(1).child(2).children().get(0).children().get(7).text());

base+=scanner.nextInt();

}

}else if (e.child(1).child(0).toString().contains("课堂小测")){

if (e.child(1).child(2).toString().contains("已参与 ")){

Scanner scanner=new Scanner(e.child(1).child(2).children().get(0).children().get(7).text());

test+=scanner.nextInt();

}

}else if (e.child(1).child(0).toString().contains("编程题")){

if (e.child(1).child(2).toString().contains("已参与 ")){

Scanner scanner=new Scanner(e.child(1).child(2).children().get(0).children().get(7).text());

program+=scanner.nextInt();

}

}else if (e.child(1).child(0).toString().contains("附加题")){

if (e.child(1).child(2).toString().contains("已参与 ")){

Scanner scanner=new Scanner(e.child(1).child(2).children().get(0).children().get(7).text());

add+=scanner.nextInt();

}

}

}

}

//计算总分

double r_before = before / t_before * 100 * 0.25;

double r_base = base / t_base * 100 * 0.3 * 0.95;

double r_test = test / t_test * 100 * 0.2;

double r_program = program / f_program * 100 * 0.1;

double r_add = add / f_add * 100 * 0.05;

double t_score = (r_add + r_base + r_before + r_program + r_test) * 0.9 + 6;

return t_score;

}

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值