标签:www. 自动生成 href 文件 ble 输出 运算 hive amp
IntNumber
类,用来实现整数的四则运算Fraction
类,用来实现真分数的四则运算Judgement
类,用来判断用户输入与实际计算值是否相等,并统计正确的次数import java.util.*;
public class Calculate {
public static void main(String[] args) {
NumberFormat nf = NumberFormat.getPercentInstance();
···
Random ran = new Random();
Scanner scan = new Scanner(System.in);
IOFile iof = new IOFile("Exercises.txt");//处理生成题目并输出到文件
while (true) {
System.out.print("请输入您所需要的题目数量:");
int A = scan.nextInt();
for (int i = 0; i < A; i++) {
int B = ran.nextInt(2);
int C = ran.nextInt(4);
in1 = IntNumber.obj();
in2 = IntNumber.obj();
score1 = Score.obj();
score2 = Score.obj();
if (B == 0) {
switch (C) {
case 0:
num = in1.add(in2);
S1 =in1.toString()+ " + " + in2.toString() + "=";
num1 = "" + num;
iof.WriteQuestionsToFile(S1);//调用append方法,将题目写入文件
N = scan.nextInt();
CorrectJudgment.judgment(N == num, num1);
break;
case 1:
···
case 2:
···
case 3:
···
}
} else {
switch (C) {
case 0:
num2 = score1.add(score2);
num1 = num2.toString();
Q = scan.next();
S2 =score1.toString()+"+"+score2.toString()+"=";
iof.WriteQuestionsToFile(S2);//调用append方法,将题目写入文件
CorrectJudgment.judgment(Q.equals(num1), num1);
break;
case 1:
···
case 2:
···
case 3:
···
}
}
}
System.out.println("你答对的题目总数:" + CorrectJudgment.getTrues());
double T = (double) CorrectJudgment.getTrues() / A;
System.out.println("您的正确率为:" + nf.format(T));
System.out.println("是否继续生成题目?(y/n):" );
String s1 = scan.next();
if (s1.equalsIgnoreCase("n")){
break;
}
}
}
}
import java.util.Random;
public class Fraction {
private int numerator, denominator;
···
public Fraction add(Fraction op2)//实现真分数加法
{
int commonDenominator = denominator * op2.getDenominator();
int numerator1 = numerator * op2.getDenominator();
int numerator2 = op2.getNumerator() * denominator;
int sum = numerator1 + numerator2;
System.out.print("("+this.toString()+")" + " + " + "("+op2.toString()+")" + "=");
return new Fraction (sum, commonDenominator);
}
public Fraction subtract(Fraction op2)//实现真分数减法
{
int commonDenominator = denominator * op2.getDenominator();
int numerator1 = numerator * op2.getDenominator();
int numerator2 = op2.getNumerator() * denominator;
int difference = numerator1 - numerator2;
System.out.print("("+this.toString()+")" + " - " + "("+op2.toString()+")" + "=");
return new Fraction(difference,commonDenominator);
}
public Fraction multiply (Fraction op2)//实现真分数乘法
{
int numer = numerator * op2.getNumerator();
int denom = denominator * op2.getDenominator();
System.out.print("("+this.toString()+")" + " * " + "("+op2.toString()+")" + "=");
return new Fraction (numer, denom);
}
public Fraction divide (Fraction op2)//实现真分数除法
{
int numer = numerator * op2.getDenominator();
int denom = denominator * op2.getNumerator();
System.out.print("("+this.toString()+")" + " / " + "("+op2.toString()+")" + "=");
return new Fraction (numer, denom);
}
···
private void reduce()//化简
{
if (numerator != 0)
{
int common = gcd (Math.abs(numerator), denominator);
numerator = numerator / common;
denominator = denominator / common;
}
}
private int gcd (int num1, int num2)//求最大公因子
{
if(num2==0)
return num1;
else
return gcd(num2,num1%num2);
}
public static Fraction obj(){
Random ran = new Random();
return new Fraction(ran.nextInt(20),ran.nextInt(20));
}
}
IntNumber类的方法测试
Fraction类的方法测试
https://gitee.com/BESTI-IS-JAVA-2018/20165230/commit/a8633b2aec49a9632cfea1e732035e8f86073b73
toString()
方法即可显示本周主要是在上一周的基础上进行需求扩展,我们分工独立完成,最终进行汇总并总结。由我实现支持自动生成题目并写入到文件的功能。在扩展的过程中发现自己学过的许多知识不会运用于实际,通过不断的查资料,查书,通过博客进行再学习,才独立完成了该功能的实现。在这个过程中将所学过的知识融会贯通,运用于实际,使我对知识点有了更深的理解与掌握。通过和杉杉交流总结,我们体会到了“纸上得来终觉浅,绝知此事要躬行”,不仅如此,还应多扩展知识的深度和广度,等到需要用时,便不会像无头苍蝇一样东拼西凑。
PSP | Personal Software Process Stages) | 预估耗时(分钟) | 实际耗时(分钟) | |
---|---|---|---|---|
Planning | 计划 | |||
Estimate | 估计这个任务需要多少时间 | 360 | 500 | |
Development | 开发 | |||
Analysis | 需求分析 (包括学习新技术) | 60 | 65 | |
Design Spec | 生成设计文档 | 30 | 35 | |
Design Review | 设计复审 (和同事审核设计文档) | 25 | 20 | |
Coding Standard | 代码规范 (为目前的开发制定合适的规范) | 15 | 30 | |
Design | 具体设计 | 75 | 95 | |
Coding | 具体编码 | 230 | 300 | |
Code Review | 代码复审 | 30 | 25 | |
Test | 测试(自我测试,修改代码,提交修改) | 150 | 135 | |
Reporting | 报告 | |||
Test Report | 测试报告 | 20 | 25 | |
Size Measurement | 计算工作量 | 10 | 5 | |
Postmortem & Process Improvement Plan | 事后总结, 并提出过程改进计划 | 60 | 80 | |
合计 | 730 | 820 |
标签:www. 自动生成 href 文件 ble 输出 运算 hive amp
原文地址:https://www.cnblogs.com/tiankunye/p/8903656.html