首页 > 其他分享 >结对项目

结对项目

时间:2024-09-28 17:49:52浏览次数:1  
标签:结对 String 项目 int expArr System println new

这个作业属于哪个课程 https://edu.cnblogs.com/campus/gdgy/CSGrade22-12
这个作业要求在哪里 https://edu.cnblogs.com/campus/gdgy/CSGrade22-12/homework/13221
姓名 学号 阿依努尔•麦麦提艾麦尔 3222004805
Github项目地址 https://github.com/3636492812/3636492812
PSP2.1 Personal Software Process Stages 预估耗时 (分钟) 实际耗时(分钟)
Planning 计划 30 30
·Estimate ·估计这个任务需要多少时间 30 30
Development 开发 1010 1370
·Analysis ·需求分析(包括学习新技术) 50 40
·Design Spec ·生成设计文档 20 20
·Design Review ·设计复审 10 5
·Coding Standard ·代码规范(为目前的开发制定合适的规范) 10 15
·Design ·具体设计 30 40
·Coding ·具体编码 850 1150
·Code Review ·代码复审 30 60
·Test ·测试(自我测试,修改代码,提交修改) 10 40
Reporting 报告 65 75
·Test Repor ·测试报告 30 40
·Size Measurement ·计算工作量 15 10
·Postmortem & Process Improvement Plan ·事后总结,并提出过程改进计划 20 25
合计 1475 1720

具体代码实现

public static void main(String[] args){
     Scanner sc= new Scanner(System.in);
     System.out.println("请输入产生几以内的数字:");
     range=sc.nextInt();
     System.out.println("请输入产生多少个运算表达式:");
     int num=sc.nextInt();
     int rightcount[]=new int[num+2];
     int wrongcount[]=new int[num+2];
     int right1=0;
    int wrong1=0;
    String[] results=new String[num];int i;
     for( i=0;i<num;i++){ 
          /*具体的功能如下面的代码(两个class除外)*/

}

生成题目:

String expArr[]=new String[2];//定义生成的题目
        int a= (int) (random.nextInt(range));//分子
        int b= (int) (random.nextInt(range));//分母
        int c= (int) (random.nextInt(range));//另一个分子
        int d= (int) (random.nextInt(range));//另一个分母
        int fuhao;//运算符
        fuhao= (int) (random.nextInt(4));
        if(b!=0&&d!=0) {//分母均不为0时生成带有分数的计算题,同时计算结果
        if(fuhao==0) {
            int fenzi=a*d+b*c;
            int fenmu=b*d;
            expArr[0]=biaodashi(a,b)+'+'+biaodashi(c,d)+'=';
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);
        
        }
        if(fuhao==1&&a*d-b*c>=0) {
            int fenzi=a*d-b*c;
            int fenmu=b*d;
            expArr[0]=biaodashi(a,b)+'-'+biaodashi(c,d)+'=';
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);
            
        }
        if(fuhao==1&&a*d-b*c<0) {
            int fenzi=b*c-a*d;
            int fenmu=b*d;
            expArr[0]=biaodashi(a,b)+'-'+biaodashi(c,d)+'=';
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);
            
        }
        if(fuhao==2) {
            int fenzi=a*c;
            int fenmu=b*d;
            expArr[0]=biaodashi(a,b)+'×'+biaodashi(c,d)+'=';
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);
            
        }
        if(fuhao==3&&c!=0) {
            int fenzi=a*d;
            int fenmu=b*c;
            expArr[0]=biaodashi(a,b)+'÷'+biaodashi(c,d)+'=';
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);
            
        }
        if(fuhao==3&&c==0) {
            break;
            /*c=1;
            int fenzi=a*d;
            int fenmu=b*c;
            expArr[0]=biaodashi(a,b)+'÷'+biaodashi(c,d)+'=';
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);*/
            
        }
        
        }
        else {//分母至少一个为0时生成只含有整式的运算式,同时计算结果
            b=1; d=1;
            if(fuhao==0) {
            int fenzi=a*d+b*c;
            int fenmu=b*d;
            expArr[0]=a+"+"+c+"=";
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);//计算结果
            
        }
        if(fuhao==1&&a*d-b*c>=0) {
            int fenzi=a*d-b*c;
            int fenmu=b*d;
            expArr[0]=a+"-"+c+"=";
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);//计算结果

            
        }
        if(fuhao==1&&a*d-b*c<0) {
            int fenzi=b*c-a*d;
            int fenmu=b*d;
            expArr[0]=c+"-"+a+"=";
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);//计算结果

            
        }
        if(fuhao==2) {
            int fenzi=a*c;
            int fenmu=b*d;
            expArr[0]=c+"×"+a+"=";
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);//计算结果

            
        }
        if(fuhao==3&&c!=0) {
            int fenzi=a*d;
            int fenmu=b*c;
            expArr[0]=a+"÷"+c+"=";
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);//计算结果

            
        }
        if(fuhao==3&&c==0) {
            break;//排除分母为零的情况
            /*c=1;
            int fenzi=a*d;
            int fenmu=b*c;
            expArr[0]=a+"÷"+c+"=";
            System.out.println(expArr[0]);
            results[i]=reductionofFraction(fenzi, fenmu);*/
            
        }

对分数的处理:

public static String reductionofFraction(int a, int b) {// 结果的分数约分,用于计算结果
        int y = 1;
        for (int i = a; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                y = i;
                break;
            }
        }
        int z = a / y;// 分子
        int m = b / y;// 分母
        if (z == 0) {
            return "0";
        }
        if(m==1) return z+"";
        else  return biaodashi(z,m);
        
    }
    public static String biaodashi(int a,int b) {//判断假分数,并化假分数为带分数
        if(a>=b) {
            int c;
            c=a/b;
            int d;
            d=a%b; 
            {if(d==0) {return c+"";}
            return c+"'"+d+"/"+b;}
        }return a+"/"+b;
    }

生成题目文件及答案文件:

FileWriter fw = null;
    try {
   
        File f=new File("Exersies.txt");//题目写入
        fw = new FileWriter(f, true);
    } catch (IOException e) {
        e.printStackTrace();
    }if(expArr[0]!=null) {
    PrintWriter pw = new PrintWriter(fw);
    pw.println(i+1+"."+expArr[0]);
    pw.flush();
    try {
        fw.flush();
        pw.close();
        fw.close();
    } catch (IOException e) {
        e.printStackTrace();
    }}FileWriter fn = null;
    try {
        
            File f=new File("Answer.txt");//答案写入
            fn = new FileWriter(f, true);
        } catch (IOException e) {
            e.printStackTrace();
        }if(expArr[0]!=null) {
        PrintWriter pn = new PrintWriter(fn);
        pn.println(i+1+"."+results[i]);
        pn.flush();
        try {
            fn.flush();
            pn.close();
            fn.close();
        } catch (IOException e) {
            e.printStackTrace();
        }}
 

统计并输出答题者的情况:

System.out.println("输入ok提交!");//答题完成后输入ok即可提交
     Scanner sc1=new Scanner(System.in);
     String submit=sc1.nextLine();
        if(submit.equals("ok")){
     String array[]=new String[num];
     try
        {   int k=0;
            
            FileReader fr = new FileReader("H://eclipse2//eclipse3//sizeyusuan//Your_answers.txt");
            BufferedReader br = new BufferedReader(fr);
            String s ;
            while((s = br.readLine())!=null) {//读取小学生的答案
                array[k]=s;    k++;
                }br.close();
            fr.close();        
            }catch(IOException e){
                System.out.println("指定文件不存在");
            }
    for(int j=0;j<num;j++){
         if(array[j].equals(results[j])) {//验证答案,统计正确和错误的个数
             
             rightcount[j]=j+1;
             right1++;
         }
         else {
             
             wrongcount[j]=j+1;
             wrong1++;
         }
     }
    FileWriter fg = null;
    try {
        //反馈正确与错误题目的信息
            File f=new File("Grade.txt");
            fg = new FileWriter(f, true);
        } catch (IOException e) {
            e.printStackTrace();
        }
        PrintWriter pg = new PrintWriter(fg);
        pg.println(" ");
        pg.print("Correct:"+right1+"(");
        for (int j = 0; j <= num; j++) {
            if (rightcount[j] != 0) {
                 pg.print(rightcount[j] + ",");
            }
        }
        pg.println(")");
        pg.print("Wrong:"+wrong1+"(");
        for (int j = 0; j <= num; j++) {
            if (wrongcount[j] != 0) {
                 pg.print(wrongcount[j] + ",");
            }
        }
        pg.print(")");
        pg.flush();
        try {
            fg.flush();
            pg.close();
            fg.close();
        } catch (IOException e) {
            e.printStackTrace();
        }}

测试运行

题目文件

答案文件

答题者答案文件

校对文件

项目小结

1.每道题目中出现的运算符个数我们只实现了单个运算符,当我们后来试图扩展多个运算符的时候发现时间不够了,因此只能上交较为简单的版本。

2.查重功能以我们的算法和我们的能力感觉实现有难度,所以并不在我们的计划中。

3.遇到的困难主要是数组越界,通过严谨的检查以及步步验证的方式找出了错误并解决了。另一个须待解决的问题是生成题目的速度有些缓慢,因此完善了多次的算法来提高代码的执行效率。

4.总的来说,在结对编程中我们有各自的想法,通过代码的形式来进行人与人之间的交流不失为一种好的方法,在这个过程中我们培养了团队协作的能力和与他人交际的能力,同时也促使自身的编程能力不断提高,这使我们都受益匪浅。当然如果还有机会的话,我还是希望可以实现带括号的运算式的生成以及答案的计算。

标签:结对,String,项目,int,expArr,System,println,new
From: https://www.cnblogs.com/aynur/p/18438224

相关文章

  • 结对项目
    3122004629杨森3122006504钟礼骏作业要求https://edu.cnblogs.com/campus/gdgy/CSGrade22-34/homework/13230作业目标用c++代码实现小学四则运算,记录PSP表格GitHub链接https://github.com/sunshyys/sizeyunsuan/tree/main函数如下:1.random():给定最大数范围后......
  • 结对项目
    结对项目这个作业属于哪个课程计科12班这个作业要求在哪里作业这个作业的目标与团队分工合作做一个小项目团队成员信息成员姓名学号班级范志杰3122004345计科1班杨文聪3122004372计科1班项目需求使用-n参数控制生成题目的个数,例如M......
  • 今日指数项目股票成交量对比功能
    股票成交量对比功能1.股票成交量对比功能分析1.1模型示列功能描述:统计A股大盘T日和T-1日成交量对比功能(成交量为沪深两市成交量之和)1.2接口示列返回数据格式服务路径:/api/quot/stock/tradeAmt服务方法:GET前端请求频率:每分钟请求参数:无{"code":1,"da......
  • 结对项目
    这个作业属于哪个课程https://edu.cnblogs.com/campus/gdgy/CSGrade22-34这个作业要求在哪里https://edu.cnblogs.com/campus/gdgy/CSGrade22-34/homework/13230这个作业的目标完成一个四则运算项目来了解项目开发流程项目成员李建龙github地址:https://git......
  • .Net8使用Cli命令创建基础项目
    第一步:创建项目结构#创建解决方案dotnetnewsln-nFxcdFx#创建WebAPI层dotnetnewwebapi-nFx.WebApi#创建Application层dotnetnewclasslib-nFx.Application#创建Domain层dotnetnewclasslib-nFx.Domain#创建Infrastructure层dotnetne......
  • 黑马PM-内容项目-需求分析
    需求分析的定义需求分析的时机需求分析的步骤......
  • DC00020基于springboot新闻网站系统java web项目MySQL新闻管理系统
    1、项目功能演示DC00020基于springboot新闻网站系统javaweb项目MySQL2、项目功能描述  基于springboot+vue新闻网站包括用户和系统管理员两个角色。2.1用户功能1、用户登录、用户注册2、新闻信息:点赞、点踩、收藏、查看3、用户分享:点赞、点踩、收藏、查看、添加......
  • 软件工程结对项目
    结对项目这个作业属于哪个课程https://edu.cnblogs.com/campus/gdgy/CSGrade22-34/这个作业要求在哪里https://edu.cnblogs.com/campus/gdgy/CSGrade22-34/homework/13230这个作业的目标结对完成四则运算生成器项目成员伍绍雄学号3122004753陈鸿航学号3......
  • 结队项目
    这个作业属于哪个课程https://edu.cnblogs.com/campus/gdgy/CSGrade22-34这个作业要求在哪里https://edu.cnblogs.com/campus/gdgy/CSGrade22-34/homework/13230这个作业的目标实现四则运算程序,掌握结对合作完成项目的技巧成员一王佳伟3122004880成员二范圣......
  • 项目实战:Qt+OSG爆破动力学仿真三维引擎测试工具v1.1.0(加载.K模型,子弹轨迹模拟动画,支持
    若该文为原创文章,转载请注明出处本文章博客地址:https://hpzwl.blog.csdn.net/article/details/142454993长沙红胖子Qt(长沙创微智科)博文大全:开发技术集合(包含Qt实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬结合等等)持续更新中…Qt开发专栏:项目实战......