软工结对编程作业

一、结对信息

1.1 结对编程成员:

蒋勃超:201521123087

谢季努:201521123079

1.2 项目开发的码云地址:https://gitee.com/jbc1132/jbc1/blob/6c8f278bedba41d70802c3334c0afd08b42eafba/jbc1.java

1.3 选择修改的程序代码:

个人博客地址5:http://www.cnblogs.com/NianQiFeng ,源代码:https://git.coding.net/qwx_hh/java-szys.git

1.4 码云提交记录:

二、需求分析:

针对现有代码的改进分析,新开发功能的分析。

现有代码改进分析

目前就发现了两个bug,一个是功能键“复习”,他会回到主页面再次进行做题,功能键与实际内容不符,所以修改了功能键名称为“继续”。

另一个是他的正确率的计算有误,第一次运行程序的时候,计算出来的正确率结果是正确的,当点击了“继续”并再次做题之后,他的正确题数rn会累加,导致正确率计算出错,因此,我们在显示正确率之后令“rn=0.0”,避免他的累加。

程序设计:针对新开发功能做设计,建议使用思维导图。

原本打算用二叉树来做随机算术题的产生。但后来观察了源代码,如果要使用二叉树的话要把他们的源代码全部推翻重来,如此一来,将耗费大量的时间与精力,于是后来还是放弃了,选择了一个较为简单,而且契合恶源代码的方法。

代码如下:

复制代码

import java.util.Random;
import java.util.Scanner;
public class jbc1 {
    public static void main(String[] args){
        int x,y,z,p,g;
        int a,b,c,m,n;
        int h = 0;
        System.out.printf("请输入需要生成的题目数量:");
        Scanner d = new Scanner(System.in);
        x = d.nextInt();
        for(int i = 0 ; i < x ; i++){
            Random aa = new Random();
            Random bb = new Random();
            Random cc = new Random();
            Random mm = new Random();
            Random nn = new Random();
            a = aa.nextInt(10);
            b = bb.nextInt(10);
            c = cc.nextInt(4);
            m = mm.nextInt(10);
            n = nn.nextInt(10);
            if(c==0){
                if(m==0&&n==0){
                    m = mm.nextInt(10)+1;
                    n = nn.nextInt(10)+1;
                    if(a%m==0&&b%n==0){
                        y = a + b;
                        System.out.printf(a+"+"+b+"= ");
                        Scanner e1 = new Scanner(System.in);
                        z = e1.nextInt();
                        if(z==y){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+y);
                        }
                    }else if(a%m==0&&b%n!=0){
                        String l = b + "/" + n;
                        y = a*n + b ;
                        System.out.printf(a+"+"+l+"= ");
                        String k =  y + "/"+ n;
                        Scanner e6 = new Scanner(System.in);
                        String j = e6.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else if(a%m!=0&&b%n==0){
                        String l = a + "/" + m;
                        y = a + b*m;
                        System.out.printf(l+"+"+b+"= ");
                        String k =  y + "/"+ m;
                        Scanner e7 = new Scanner(System.in);
                        String j = e7.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else{
                        String l1 = a + "/" + m;
                        String l2 = b + "/" + n;
                        y = a*n + b*m;
                        System.out.printf(l1+"+"+l2+"= ");
                        String k =  y + "/"+ n*m;
                        Scanner e8 = new Scanner(System.in);
                        String j = e8.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }
                }else if(m==0&&n!=0){
                    m = mm.nextInt(10)+1;
                    if(a%m==0&&b%n==0){
                        y = a + b;
                        System.out.printf(a+"+"+b+"= ");
                        Scanner e1 = new Scanner(System.in);
                        z = e1.nextInt();
                        if(z==y){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+y);
                        }
                    }else if(a%m==0&&b%n!=0){
                        String l = b + "/" + n;
                        y = a*n + b ;
                        System.out.printf(a+"+"+l+"= ");
                        String k =  y + "/"+ n;
                        Scanner e6 = new Scanner(System.in);
                        String j = e6.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else if(a%m!=0&&b%n==0){
                        String l = a + "/" + m;
                        y = a + b*m;
                        System.out.printf(l+"+"+b+"= ");
                        String k =  y + "/"+ m;
                        Scanner e7 = new Scanner(System.in);
                        String j = e7.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else{
                        String l1 = a + "/" + m;
                        String l2 = b + "/" + n;
                        y = a*n + b*m;
                        System.out.printf(l1+"+"+l2+"= ");
                        String k =  y + "/"+ n*m;
                        Scanner e8 = new Scanner(System.in);
                        String j = e8.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }
                }else if(m!=0&&n==0){
                    n = nn.nextInt(10)+1;
                    if(a%m==0&&b%n==0){
                        y = a + b;
                        System.out.printf(a+"+"+b+"= ");
                        Scanner e1 = new Scanner(System.in);
                        z = e1.nextInt();
                        if(z==y){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+y);
                        }
                    }else if(a%m==0&&b%n!=0){
                        String l = b + "/" + n;
                        y = a*n + b ;
                        System.out.printf(a+"+"+l+"= ");
                        String k =  y + "/"+ n;
                        Scanner e6 = new Scanner(System.in);
                        String j = e6.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else if(a%m!=0&&b%n==0){
                        String l = a + "/" + m;
                        y = a + b*m;
                        System.out.printf(l+"+"+b+"= ");
                        String k =  y + "/"+ m;
                        Scanner e7 = new Scanner(System.in);
                        String j = e7.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else{
                        String l1 = a + "/" + m;
                        String l2 = b + "/" + n;
                        y = a*n + b*m;
                        System.out.printf(l1+"+"+l2+"= ");
                        String k =  y + "/"+ n*m;
                        Scanner e8 = new Scanner(System.in);
                        String j = e8.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }
                }else{
                    if(a%m==0&&b%n==0){
                        y = a + b;
                        System.out.printf(a+"+"+b+"= ");
                        Scanner e1 = new Scanner(System.in);
                        z = e1.nextInt();
                        if(z==y){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+y);
                        }
                    }else if(a%m==0&&b%n!=0){
                        String l = b + "/" + n;
                        y = a*n + b ;
                        System.out.printf(a+"+"+l+"= ");
                        String k =  y + "/"+ n;
                        Scanner e6 = new Scanner(System.in);
                        String j = e6.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else if(a%m!=0&&b%n==0){
                        String l = a + "/" + m;
                        y = a + b*m;
                        System.out.printf(l+"+"+b+"= ");
                        String k =  y + "/"+ m;
                        Scanner e7 = new Scanner(System.in);
                        String j = e7.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else{
                        String l1 = a + "/" + m;
                        String l2 = b + "/" + n;
                        y = a*n + b*m;
                        System.out.printf(l1+"+"+l2+"= ");
                        String k =  y + "/"+ n*m;
                        Scanner e8 = new Scanner(System.in);
                        String j = e8.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }
                }
            }
            if(c==1){
                if(m==0&&n==0){
                    m = mm.nextInt(10)+1;
                    n = nn.nextInt(10)+1;
                    if(a%m==0&&b%n==0){
                        y = a - b;
                        System.out.printf(a+"-"+b+"= ");
                        Scanner e2 = new Scanner(System.in);
                        z = e2.nextInt();
                        if(z==y){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+y);
                        }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    y = a*n - b ;
                    System.out.printf(a+"-"+l+"= ");
                    String k =  y + "/"+ n;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a - b*m;
                    System.out.printf(l+"-"+b+"= ");
                    String k =  y + "/"+ m;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n - b*m;
                    System.out.printf(l1+"-"+l2+"= ");
                    String k =  y + "/"+ n*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
                }else if(m==0&&n!=0){
                m = mm.nextInt(10)+1;
                if(a%m==0&&b%n==0){
                    y = a - b;
                    System.out.printf(a+"-"+b+"= ");
                    Scanner e1 = new Scanner(System.in);
                    z = e1.nextInt();
                    if(z==y){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+y);
                    }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    y = a*n - b ;
                    System.out.printf(a+"-"+l+"= ");
                    String k =  y + "/"+ n;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a - b*m;
                    System.out.printf(l+"-"+b+"= ");
                    String k =  y + "/"+ m;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n - b*m;
                    System.out.printf(l1+"-"+l2+"= ");
                    String k =  y + "/"+ n*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
            }else if(m!=0&&n==0){
                n = nn.nextInt(10)+1;
                if(a%m==0&&b%n==0){
                    y = a - b;
                    System.out.printf(a+"-"+b+"= ");
                    Scanner e1 = new Scanner(System.in);
                    z = e1.nextInt();
                    if(z==y){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+y);
                    }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    y = a*n - b ;
                    System.out.printf(a+"-"+l+"= ");
                    String k =  y + "/"+ n;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a - b*m;
                    System.out.printf(l+"-"+b+"= ");
                    String k =  y + "/"+ m;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n - b*m;
                    System.out.printf(l1+"-"+l2+"= ");
                    String k =  y + "/"+ n*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
            }else{
                if(a%m==0&&b%n==0){
                    y = a - b;
                    System.out.printf(a+"-"+b+"= ");
                    Scanner e1 = new Scanner(System.in);
                    z = e1.nextInt();
                    if(z==y){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+y);
                    }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    y = a*n - b ;
                    System.out.printf(a+"-"+l+"= ");
                    String k =  y + "/"+ n;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a - b*m;
                    System.out.printf(l+"-"+b+"= ");
                    String k =  y + "/"+ m;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n - b*m;
                    System.out.printf(l1+"-"+l2+"= ");
                    String k =  y + "/"+ n*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
            }
            }
            if(c==2){
                if(m==0&&n==0){
                    m = mm.nextInt(10)+1;
                    n = nn.nextInt(10)+1;
                    if(a%m==0&&b%n==0){
                        y = a * b;
                        System.out.printf(a+"x"+b+"= ");
                        Scanner e3 = new Scanner(System.in);
                        z = e3.nextInt();
                        if(z==y){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+y);
                        }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    y = a*b ;
                    System.out.printf(a+"x"+l+"= ");
                    String k =  y + "/"+ n;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = b*a;
                    System.out.printf(l+"x"+b+"= ");
                    String k =  y + "/"+ m;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*b;
                    System.out.printf(l1+"x"+l2+"= ");
                    String k =  y + "/"+ n*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
                }else if(m==0&&n!=0){
                m = mm.nextInt(10)+1;
                if(a%m==0&&b%n==0){
                    y = a * b;
                    System.out.printf(a+"x"+b+"= ");
                    Scanner e1 = new Scanner(System.in);
                    z = e1.nextInt();
                    if(z==y){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+y);
                    }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    y = a*b;
                    System.out.printf(a+"x"+l+"= ");
                    String k =  y + "/"+ n;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a*b;
                    System.out.printf(l+"x"+b+"= ");
                    String k =  y + "/"+ m;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*b;
                    System.out.printf(l1+"x"+l2+"= ");
                    String k =  y + "/"+ n*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
            }else if(m!=0&&n==0){
                n = nn.nextInt(10)+1;
                if(a%m==0&&b%n==0){
                    y = a * b;
                    System.out.printf(a+"x"+b+"= ");
                    Scanner e1 = new Scanner(System.in);
                    z = e1.nextInt();
                    if(z==y){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+y);
                    }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    y = a*b ;
                    System.out.printf(a+"x"+l+"= ");
                    String k =  y + "/"+ n;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a*b;
                    System.out.printf(l+"x"+b+"= ");
                    String k =  y + "/"+ m;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*b;
                    System.out.printf(l1+"x"+l2+"= ");
                    String k =  y + "/"+ n*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
            }else{
                if(a%m==0&&b%n==0){
                    y = a * b;
                    System.out.printf(a+"x"+b+"= ");
                    Scanner e1 = new Scanner(System.in);
                    z = e1.nextInt();
                    if(z==y){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+y);
                    }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    y = a*b ;
                    System.out.printf(a+"x"+l+"= ");
                    String k =  y + "/"+ n;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a*b;
                    System.out.printf(l+"x"+b+"= ");
                    String k =  y + "/"+ m;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*b;
                    System.out.printf(l1+"x"+l2+"= ");
                    String k =  y + "/"+ n*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
            }
            }
            if(c==3){
                if(b==0){
                    b = bb.nextInt(10)+1;
                    if(m==0&&n==0){
                        m = mm.nextInt(10)+1;
                        n = nn.nextInt(10)+1;
                        if(a%m==0&&b%n==0){
                            if(a%b!=0){
                                String l=a+"/"+b;
                            System.out.printf(a+"÷"+b+"= ");
                            Scanner e4 = new Scanner(System.in);
                            String p1 = e4.next();
                            if(p1.equals(l)){
                                System.out.println("回答正确!");
                                h++;
                            }else{
                                System.out.println("回答错误!正确答案是"+l);
                            }
                            }else{
                                p = a / b;
                                System.out.printf(a+"÷"+b+"= ");
                                Scanner e5 = new Scanner(System.in);
                                g = e5.nextInt();
                                if(p==g){
                                    System.out.println("回答正确!");
                                    h++;
                                }else{
                                    System.out.println("回答错误!正确答案是"+p);
                                }
                            }
                    }else if(a%m==0&&b%n!=0){
                        String l = b + "/" + n;
                        if(a==0){System.out.println(a+"÷"+l+"= ");
                        Scanner e6 = new Scanner(System.in);
                        p = e6.nextInt();
                        if(p==0){System.out.println("回答正确!");h++;
                        continue;}else{System.out.println("回答错误!正确答案是0");continue;}
                        }
                        y = a*n ;
                        System.out.printf(a+"÷"+l+"= ");
                        String k =  y + "/"+ b;
                        Scanner e6 = new Scanner(System.in);
                        String j = e6.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else if(a%m!=0&&b%n==0){
                        String l = a + "/" + m;
                        y = a;
                        System.out.printf(l+"÷"+b+"= ");
                        String k =  y + "/"+ m*b;
                        Scanner e7 = new Scanner(System.in);
                        String j = e7.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else{
                        String l1 = a + "/" + m;
                        String l2 = b + "/" + n;
                        y = a*n;
                        System.out.printf(l1+"÷"+l2+"= ");
                        String k =  y + "/"+ b*m;
                        Scanner e8 = new Scanner(System.in);
                        String j = e8.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }
                    }else if(m==0&&n!=0){
                    m = mm.nextInt(10)+1;
                    if(a%m==0&&b%n==0){
                        if(a%b!=0){
                            String l=a+"/"+b;
                        System.out.printf(a+"÷"+b+"= ");
                        Scanner e4 = new Scanner(System.in);
                        String p1 = e4.next();
                        if(p1.equals(l)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+l);
                        }
                        }else{
                            p = a / b;
                            System.out.printf(a+"÷"+b+"= ");
                            Scanner e5 = new Scanner(System.in);
                            g = e5.nextInt();
                            if(p==g){
                                System.out.println("回答正确!");
                                h++;
                            }else{
                                System.out.println("回答错误!正确答案是"+p);
                            }
                        }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    if(a==0){System.out.println(a+"÷"+l+"= ");
                    Scanner e6 = new Scanner(System.in);
                    p = e6.nextInt();
                    if(p==0){System.out.println("回答正确!");h++;
                    continue;}else{System.out.println("回答错误!正确答案是0");continue;}
                    }
                    y = a*n ;
                    System.out.printf(a+"÷"+l+"= ");
                    String k =  y + "/"+ b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a;
                    System.out.printf(l+"÷"+b+"= ");
                    String k =  y + "/"+ m*b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n;
                    System.out.printf(l1+"÷"+l2+"= ");
                    String k =  y + "/"+ b*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
                }else if(m!=0&&n==0){
                    n = nn.nextInt(10)+1;
                    if(a%m==0&&b%n==0){
                        if(a%b!=0){
                            String l=a+"/"+b;
                        System.out.printf(a+"÷"+b+"= ");
                        Scanner e4 = new Scanner(System.in);
                        String p1 = e4.next();
                        if(p1.equals(l)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+l);
                        }
                        }else{
                            p = a / b;
                            System.out.printf(a+"÷"+b+"= ");
                            Scanner e5 = new Scanner(System.in);
                            g = e5.nextInt();
                            if(p==g){
                                System.out.println("回答正确!");
                                h++;
                            }else{
                                System.out.println("回答错误!正确答案是"+p);
                            }
                        }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    if(a==0){System.out.println(a+"÷"+l+"= ");
                    Scanner e6 = new Scanner(System.in);
                    p = e6.nextInt();
                    if(p==0){System.out.println("回答正确!");h++;
                    continue;}else{System.out.println("回答错误!正确答案是0");continue;}
                    }
                    y = a*n ;
                    System.out.printf(a+"÷"+l+"= ");
                    String k =  y + "/"+ b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a;
                    System.out.printf(l+"÷"+b+"= ");
                    String k =  y + "/"+ m*b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n;
                    System.out.printf(l1+"÷"+l2+"= ");
                    String k =  y + "/"+ b*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
                }else{
                    if(a%m==0&&b%n==0){
                        if(a%b!=0){
                            String l=a+"/"+b;
                        System.out.printf(a+"÷"+b+"= ");
                        Scanner e4 = new Scanner(System.in);
                        String p1 = e4.next();
                        if(p1.equals(l)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+l);
                        }
                        }else{
                            p = a / b;
                            System.out.printf(a+"÷"+b+"= ");
                            Scanner e5 = new Scanner(System.in);
                            g = e5.nextInt();
                            if(p==g){
                                System.out.println("回答正确!");
                                h++;
                            }else{
                                System.out.println("回答错误!正确答案是"+p);
                            }
                        }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    if(a==0){System.out.println(a+"÷"+l+"= ");
                    Scanner e6 = new Scanner(System.in);
                    p = e6.nextInt();
                    if(p==0){System.out.println("回答正确!");h++;
                    continue;}else{System.out.println("回答错误!正确答案是0");continue;}
                    }
                    y = a*n ;
                    System.out.printf(a+"÷"+l+"= ");
                    String k =  y + "/"+ b;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a;
                    System.out.printf(l+"÷"+b+"= ");
                    String k =  y + "/"+ m*b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n;
                    System.out.printf(l1+"÷"+l2+"= ");
                    String k =  y + "/"+ b*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
                }
                }else{
                //p =(float) a / b;
                    if(m==0&&n==0){
                        m = mm.nextInt(10)+1;
                        n = nn.nextInt(10)+1;
                        if(a%m==0&&b%n==0){
                            if(a%b!=0){
                                String l=a+"/"+b;
                            System.out.printf(a+"÷"+b+"= ");
                            Scanner e4 = new Scanner(System.in);
                            String p1 = e4.next();
                            if(p1.equals(l)){
                                System.out.println("回答正确!");
                                h++;
                            }else{
                                System.out.println("回答错误!正确答案是"+l);
                            }
                            }else{
                                p = a / b;
                                System.out.printf(a+"÷"+b+"= ");
                                Scanner e5 = new Scanner(System.in);
                                g = e5.nextInt();
                                if(p==g){
                                    System.out.println("回答正确!");
                                    h++;
                                }else{
                                    System.out.println("回答错误!正确答案是"+p);
                                }
                            }
                    }else if(a%m==0&&b%n!=0){
                        String l = b + "/" + n;
                        y = a*n ;
                        System.out.printf(a+"÷"+l+"= ");
                        String k =  y + "/"+ b;
                        Scanner e6 = new Scanner(System.in);
                        String j = e6.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else if(a%m!=0&&b%n==0){
                        String l = a + "/" + m;
                        if(a==0){System.out.println(a+"÷"+l+"= ");
                        Scanner e6 = new Scanner(System.in);
                        p = e6.nextInt();
                        if(p==0){System.out.println("回答正确!");h++;
                        continue;}else{System.out.println("回答错误!正确答案是0");continue;}
                        }
                        y = a;
                        System.out.printf(l+"÷"+b+"= ");
                        String k =  y + "/"+ m*b;
                        Scanner e7 = new Scanner(System.in);
                        String j = e7.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }else{
                        String l1 = a + "/" + m;
                        String l2 = b + "/" + n;
                        y = a*n;
                        System.out.printf(l1+"÷"+l2+"= ");
                        String k =  y + "/"+ b*m;
                        Scanner e8 = new Scanner(System.in);
                        String j = e8.next();
                        if(j.equals(k)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+k);
                        }
                    }
                    }else if(m==0&&n!=0){
                    m = mm.nextInt(10)+1;
                    if(a%m==0&&b%n==0){
                        if(a%b!=0){
                            String l=a+"/"+b;
                        System.out.printf(a+"÷"+b+"= ");
                        Scanner e4 = new Scanner(System.in);
                        String p1 = e4.next();
                        if(p1.equals(l)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+l);
                        }
                        }else{
                            p = a / b;
                            System.out.printf(a+"÷"+b+"= ");
                            Scanner e5 = new Scanner(System.in);
                            g = e5.nextInt();
                            if(p==g){
                                System.out.println("回答正确!");
                                h++;
                            }else{
                                System.out.println("回答错误!正确答案是"+p);
                            }
                        }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    if(a==0){System.out.println(a+"÷"+l+"= ");
                    Scanner e6 = new Scanner(System.in);
                    p = e6.nextInt();
                    if(p==0){System.out.println("回答正确!");h++;
                    continue;}else{System.out.println("回答错误!正确答案是0");continue;}
                    }
                    y = a*n ;
                    System.out.printf(a+"÷"+l+"= ");
                    String k =  y + "/"+ b;
                    Scanner e6 = new Scanner(System.in);
                    String j = e6.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a;
                    System.out.printf(l+"÷"+b+"= ");
                    String k =  y + "/"+ m*b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n;
                    System.out.printf(l1+"÷"+l2+"= ");
                    String k =  y + "/"+ b*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
                }else if(m!=0&&n==0){
                    n = nn.nextInt(10)+1;
                    if(a%m==0&&b%n==0){
                        if(a%b!=0){
                            String l=a+"/"+b;
                        System.out.printf(a+"÷"+b+"= ");
                        Scanner e4 = new Scanner(System.in);
                        String p1 = e4.next();
                        if(p1.equals(l)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+l);
                        }
                        }else{
                            p = a / b;
                            System.out.printf(a+"÷"+b+"= ");
                            Scanner e5 = new Scanner(System.in);
                            g = e5.nextInt();
                            if(p==g){
                                System.out.println("回答正确!");
                                h++;
                            }else{
                                System.out.println("回答错误!正确答案是"+p);
                            }
                        }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    if(a==0){System.out.println(a+"÷"+l+"= ");
                    Scanner e6 = new Scanner(System.in);
                    p = e6.nextInt();
                    if(p==0){System.out.println("回答正确!");h++;
                    continue;}else{System.out.println("回答错误!正确答案是0");continue;}
                    }
                    y = a*n ;
                    System.out.printf(a+"÷"+l+"= ");
                    String k =  y + "/"+ b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a;
                    System.out.printf(l+"÷"+b+"= ");
                    String k =  y + "/"+ m*b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n;
                    System.out.printf(l1+"÷"+l2+"= ");
                    String k =  y + "/"+ b*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
                }else{
                    if(a%m==0&&b%n==0){
                        if(a%b!=0){
                            String l=a+"/"+b;
                        System.out.printf(a+"÷"+b+"= ");
                        Scanner e4 = new Scanner(System.in);
                        String p1 = e4.next();
                        if(p1.equals(l)){
                            System.out.println("回答正确!");
                            h++;
                        }else{
                            System.out.println("回答错误!正确答案是"+l);
                        }
                        }else{
                            p = a / b;
                            System.out.printf(a+"÷"+b+"= ");
                            Scanner e5 = new Scanner(System.in);
                            g = e5.nextInt();
                            if(p==g){
                                System.out.println("回答正确!");
                                h++;
                            }else{
                                System.out.println("回答错误!正确答案是"+p);
                            }
                        }
                }else if(a%m==0&&b%n!=0){
                    String l = b + "/" + n;
                    if(a==0){System.out.println(a+"÷"+l+"= ");
                    Scanner e6 = new Scanner(System.in);
                    p = e6.nextInt();
                    if(p==0){System.out.println("回答正确!");h++;
                    continue;}else{System.out.println("回答错误!正确答案是0");continue;}
                    }
                    y = a*n ;
                    System.out.printf(a+"÷"+l+"= ");
                    String k =  y + "/"+ b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else if(a%m!=0&&b%n==0){
                    String l = a + "/" + m;
                    y = a;
                    System.out.printf(l+"÷"+b+"= ");
                    String k =  y + "/"+ m*b;
                    Scanner e7 = new Scanner(System.in);
                    String j = e7.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }else{
                    String l1 = a + "/" + m;
                    String l2 = b + "/" + n;
                    y = a*n;
                    System.out.printf(l1+"÷"+l2+"= ");
                    String k =  y + "/"+ b*m;
                    Scanner e8 = new Scanner(System.in);
                    String j = e8.next();
                    if(j.equals(k)){
                        System.out.println("回答正确!");
                        h++;
                    }else{
                        System.out.println("回答错误!正确答案是"+k);
                    }
                }
                }
                }
            }
        }
        System.out.println("总共"+x+"题,"+"恭喜答对"+h+"题");
        System.out.println("正确率为"+(float)h/x);
    }
}

5.PSP表格

6.小结感受:结对编程真的能够带来1+1>2的效果吗?通过这次结对编程,请谈谈你的感受和体会。

答:这次的结对编程让我深深感觉到编程的难度,并且有着许多需要自己掌握的地方,现在的我需要继续的努力来弥补自己的不足和落后

原文地址:https://www.cnblogs.com/xjn12138/p/8646825.html

时间: 2024-12-28 17:38:02

软工结对编程作业的相关文章

软工结对编程代码审查

结对编程代码审查 结对编程伙伴:刘博闻 审核程序GitHub地址:工资程序代码 一:代码审查表 功能模块名称 工资程序 审查人    郭金鑫 审查日期 2018.04.05 代码名称    工资程序 代码作者 刘博闻 文件结构 重要性       审查项 结论                  头文件和定义文件的名称是否合理? 合理 头文件和定义文件的目录结构是否合理? 合理 版权和版本声明是否完整? 完整 重要 头文件是否使用了 ifndef/define/endif 预处理块? 否 头文件中

软工结对第一次作业

代码审查表格 功能模块名称 实现C语言小子集程序的词法分析 审查人 吴琼 审查日期 2018.4.6 代码名称 词法分析程序 代码作者 杨卓辰 文件结构 cpp文件 重要性 审查项 结论 头文件和定义文件的名称是否合理? 合理 头文件和定义文件的目录结构是否合理? 合理 版权和版本声明是否完整? 完整 重要 头文件是否使用了 ifndef/define/endif 预处理块? 没有 头文件中是否只存放"声明"而不存放"定义" 没有 程序的版式 重要性 审查项 结论

结对编程作业

这是第一次尝试结对编程,在本次结对编程作业中为了更好地体会它的好处和特点,我和我的搭档分别扮演了驾驶员和领航者的角色. 作为驾驶员:在我编程的过程中,出现了一些小问题,比如忘加分号,这些小问题可以及时的发现.有时我也会问我的领航者一些疑问,省去了上网查资料的过程,提高了编程的效率.在代码复审的过程中,有的问题我在自己调试的时候没有发现.比如输入某些数据的时候,离黄金点最近的玩家得0分.还有程序的功能上的一些缺陷,也被进一步完善.编程的时候我们会有一些交流,交流使我们互相更加了解对方的编程风格,在

2016福州大学软件工程第二次结对编程作业成绩

在这里跟大家道个歉,由于国庆节基本都在参加婚礼的路上所以现在才把成绩统计汇总了一下,份子钱太吓人已经把不多的工资吃掉了,这个月要靠泡面度日了.你们可是要好好学习,好好赚钱,好出的起同学的份子钱啊.扯远了,第二次结对编程成绩统计如下: 学号 第二次结对编程 031402233 9.5 031402224 9.5 031402330 9.5 031402516 9 031402524 9 031402304 9 031402509 9 031402341 9 031402508 9 03140232

软工实践第一次作业-黄紫仪

软工实践第一次作业 前言:emmmm之前因为没太注意,想着计算机专业怎么会有软工实践.所以之前一直都没去管.等到开学才发现突然翻车.QAQ现在赶紧先来补交一下. (1)回想一下你初入大学时对计算机专业的畅想 当初你是如何做出选择计算机专业的决定的? 你认为过去两年中接触到的课程是否符合你对计算机专业的期待,为什么? 你觉得计算机是你喜欢的领域吗,它是你擅长的领域吗?   说到选择计算机,emmmm,某种意义上来说是打RPG游戏打出来的想法,因为很喜欢这类的游戏,所以也想去试着写一个属于自己的这种

第三次作业----结对编程作业

黄金点游戏是一个数字小游戏,其游戏规则是: N个同学(N通常大于10),每人写一个0-100之间的有理数 (不包括0或100),交给裁判,裁判算出所有数字的平均值,然后乘以0.618(所谓黄金分割常数),得到G值.提交的数字最靠近G(取绝对值)的同学得到N分,离G最远的同学得到-2分,其他同学得0分.玩了几天以后,大家发现了一些很有意思的现象,比如黄金点在逐渐地往下移动. 这次软件工程的作业是以结对编程的形式编写"黄金点游戏".结对编程是指两位程序员坐在同一工作台前开发软件与两位程序员

结对编程作业:四则运算

截止日期 2018年4月12日15:30 提交地址 https://github.com/eudaem/homework2 本次结对编程作业分为以下两种类型Core(计算核心)和UI(用户界面),每组任选一个完成,原则上两种类型题目各占一半 Core 像<构建之法>的人物阿超那样,写一个能自动生成小学四则运算题目并给出答案的命令行 "软件", 如果我们要把这个功能放到不同的环境中去(例如,命令行,Windows 图形界面程序,网页程序,手机App),就会碰到困难,因为目前代

软工第零次作业[补交]

目录 第一部分:结缘计算机    2 i.    你为什么选择计算机专业?你认为你的条件如何?和这些博主比呢?(必答)    2 ii.    计算机是你喜欢的领域吗?是你擅长的领域吗?    3 iii.    你热爱这一专业吗?你对计算机的热爱是怎样的?仅仅是口头的吗?    3 第二部分:在计算机系里学习    4 i.    你对你的大学生活有什么想要吐槽的地方吗?你理想的大学教育应该是什么样子的?跟学校给你的有什么区别?比较你在中国大学的经历,你的老师和学校能做到和国外那样吗?如果不能

软工实践总结作业

忽然间,说结束就结束了. 明明是一直以来觉得头疼无比.时间占用巨大的这门课程,在结束的时候,却没有想象中的轻松,反而有一丝失落. 1.课程总结: 翻开刚刚开课时写下的目标,字里行间读出的,半是憧憬,半是迷茫.计划中要做的,有一些没有完成: 原打算学习java,最后却学习了一些php和mysql: 想要学会更好的管理时间,熬夜的次数好像却更加频繁: 原以为可以初步成长为一个合格的pm,但是回头看看自己做的好像也不怎么样.. .当然,也有不少的收获: 学会了一些软件的使用,例如原型开发软件Axure