首页 > 其他分享 >测试4错误纠正

测试4错误纠正

时间:2022-09-30 19:01:26浏览次数:45  
标签:纠正 String 错误 int System static 测试 new out

没错!还是那神奇的四则运算,它,,又来啦!!!

话不多说,直接上代码!!!

本次实践,主要实现了分年级的继承功能问题、错题集整理和重做问题、查看正确率问题、还有之前已经实现过的四则运算问题,相当于“四则运算中的战斗机”了吧,好有成就感啊喂!

//Main.java
import java.util.Scanner;

public class Main{

    static int sum;
    static int count;

    er ee=new er();
    san ss=new san();
    si ii=new si();

    public static void main(String[] args) {
        menu1();
    }
    //主菜单
    public static void menu1(){
        while(true) {
            Scanner sc = new Scanner(System.in);
            System.out.println("******************");
            System.out.println("1、参数设置:");
            System.out.println("2、小学二年级口算题");
            System.out.println("3、小学三年级口算题");
            System.out.println("4、小学四年级口算题");
            System.out.println("5、错题集");
            System.out.println("******************");
            int c = sc.nextInt();
            if (c == 1) {
                can();
            }
            if(c==2){
                er.getAnswer1(sum,count);
            }
            if(c==3){
                san.getAnswer1(sum,count);
            }
            if(c==4){
                si.getAnswer1(sum,count);
            }
            if(c==5){//错题集

                System.out.println("请选择:1、二年级 2、三年级 3、四年级");
                int x=sc.nextInt();
                if(x==1){
                    er.cuoTiJi(sum);
                }
                if(x==2){
                    san.cuoTiJi(sum);
                }
                if(x==3){
                    si.cuoTiJi(sum);
                }

                System.out.println("请根据以上题目进行修正和重练");
            }
        }
    }
    //错题集

    //参数设置
    public static void can(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你想要打印的题目数量:");
        sum = sc.nextInt();//iControl用于控制生成题目总数
        System.out.println("请输入操作数的个数:");
        count = sc.nextInt();

    }


    }

//er.java
import java.util.Random;
import java.util.Scanner;

public class er{
    static int err;
    static String[] timu=new String[1001];
    static String[] error=new String[1001];
    static String[] aa=new String[1001];
    static String[] daanCom=new String[1001];
    static String[] daanPerson=new String[1001];
    static int[]cuowu1=new int[1001];
    static int[]cuowu2=new int[1001];
    public static void getAnswer1(int sum,int count){
        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        err = 0;
        int x, y ;
        for (int i = 0; i < sum; i++) {
            String str = "";//记录题目
            x = r.nextInt(1000);
            str += String.valueOf(x);
            for (int j = 0; j < count - 1; j++) {
                y = r.nextInt(1000);
                int fuhao = r.nextInt(1, 4);
                switch(fuhao) {
                    case 1:
                        str += " + ";
                        x+=y;
                        break;
                    case 2:
                        str += " - ";
                        x-=y;
                        break;
                    case 3:
                        str += " * ";
                        x=x*y;
                        break;
                    case 4:
                        str += " / ";
                        x=x/y;
                        break;
                }
                str+=String.valueOf(y);
            }
            str+=" = ";
            timu[i]=str;
            daanCom[i]=String.valueOf(x);
            System.out.print(str);
            daanPerson[i]=sc.nextLine();
            if(!(daanCom[i].equals(daanPerson[i]))) {
                cuowu1[err]=i;//cun下标
                cuowu2[cuowu1[err]]++;//存错误次数
                err++;
            }
        }
    }

    //错题集
    public static void cuoTiJi(int sum) {

        System.out.println("正确率:"+(double)(sum-err)/sum*100.0+"%");

        Scanner sc=new Scanner(System.in);

        for (int i = 0; i < err; i++) {
            System.out.println(timu[cuowu1[i]]);
        }

        System.out.println("请选择是否重做:1、是  2、否");
        int m=sc.nextInt();
        if(m==1) {
            chongZuo();
        }
    }

    public static void chongZuo(){

        Scanner sc=new Scanner(System.in);

        for (int i = 0; i < err; i++) {
            System.out.println(timu[cuowu1[i]]);
            aa[i]=sc.nextLine();
            if(!(aa[i].equals(daanCom[i]))) {
                System.out.println("答错啦!");
            }
        }
    }
}
//san.java
import java.util.Random;
import java.util.Scanner;

public class san extends er{
    static int err;
    static String[] timu=new String[1001];
    static String[] error=new String[1001];
    static String[] daanCom=new String[1001];
    static String[] daanPerson=new String[1001];
    static int[]cuowu1=new int[1001];
    static int[]cuowu2=new int[1001];
public static void getAnswer1(int sum,int count){
        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        err = 0;
        int x, y ;
        for (int i = 0; i < sum; i++) {
            String str = "";//记录题目
            x = r.nextInt(1000);
            str += String.valueOf(x);
            for (int j = 0; j < count - 1; j++) {
                y = r.nextInt(1000);
                int fuhao = r.nextInt(1, 4);
                switch(fuhao) {
                    case 1:
                        str += " + ";
                        x+=y;
                        break;
                    case 2:
                        str += " - ";
                        x-=y;
                        break;
                    case 3:
                        str += " * ";
                        x=x*y;
                        break;
                    case 4:
                        str += " / ";
                        x=x/y;
                        break;
                }
                str+=String.valueOf(y);
            }
            str+=" = ";
            timu[i]=str;
            daanCom[i]=String.valueOf(x);
            System.out.print(str);
            daanPerson[i]=sc.nextLine();
            if(!(daanCom[i].equals(daanPerson[i]))) {
                cuowu1[err]=i;//cun下标
                cuowu2[cuowu1[err]]++;//存错误次数
                err++;
            }
        }
}

//错题集
public static void cuoTiJi(int sum) {

    System.out.println("正确率:"+(double)(sum-err)/sum*100.0+"%");

    Scanner sc=new Scanner(System.in);

    for (int i = 0; i < err; i++) {
        System.out.println(timu[cuowu1[i]]);
    }

    System.out.println("请选择是否重做:1、是  2、否");
    int m=sc.nextInt();
    if(m==1) {
        chongZuo();
    }
}

    public static void chongZuo(){

        Scanner sc=new Scanner(System.in);

        for (int i = 0; i < err; i++) {
            System.out.println(timu[cuowu1[i]]);
            aa[i]=sc.nextLine();
            if(!(aa[i].equals(daanCom[i]))) {
                System.out.println("答错啦!");
            }
        }
    }
}

//si.java
import java.util.Random;
import java.util.Scanner;

public class si extends san {
    static int err;
    static String[] timu = new String[1001];
    static String[] error = new String[1001];
    static String[] daanCom = new String[1001];
    static String[] daanPerson = new String[1001];
    static int[] cuowu1 = new int[1001];
    static int[] cuowu2 = new int[1001];
    static int x;
    static int y;
    static int m1,m2,c1,c2,cc;

    public static void getAnswer1(int sum, int count) {
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        for (int j = 0; j < sum; j++) {
            String str = "";//存储题目
            boolean ss = true;
            int left = random.nextInt(count - 1);
            int right = random.nextInt(count - left) + left + 1;
            /*for (int i = 0; i < count * 2 - 1; i++) {
                getDo[i] = random.nextInt(1000);
            }
            for (int t = 0; t < count; t++) {
                admin[j] += getDo[t * 2] * t;
            }

            for (int k = 0; k < j; k++) {
                if (admin[k] == admin[j]) {
                    ss = false;
                    break;
                }
            }*/

            if(ss){

                for(int m=0;m<count-1;m++){//符号的个数
                    m1=random.nextInt(1,2);
                    if(m1==1){
                        str+="(";
                        c1++;
                    }
                    x=random.nextInt(1000);
                    str+=x;
                    y=random.nextInt(1000);
                    cc=random.nextInt(1,4);
                    if(cc==1){
                        str+="+";
                        x+=y;
                    }
                    if(cc==2){
                        str+="-";
                        x-=y;
                    }
                    if(cc==3){
                        str+="*";
                        x=x*y;
                    }
                    if(cc==4){
                        str+="/";
                        x=x/y;
                    }
                    str+=y;
                    if(c1!=0&&c1!=c2){
                        str+=")";
                        c2++;
                    }
                    cc=random.nextInt(1,4);
                    if(cc==1&&m!=count-2){
                        str+="+";
                        x+=y;
                        m++;
                    }
                    if(cc==2&&m!=count-2){
                        str+="-";
                        x-=y;
                        m++;
                    }
                    if(cc==3&&m!=count-2){
                        str+="*";
                        x=x*y;
                        m++;
                    }
                    if(cc==4&&m!=count-2){
                        str+="/";
                        x=x/y;
                        m++;
                    }

                }
                //存储题目--计算结果
                str += "=";
                timu[j] = str;
                daanCom[j] = String.valueOf(x);
                System.out.print(str);
                daanPerson[j] = sc.nextLine();
                if (!(daanCom[j].equals(daanPerson[j]))) {
                    cuowu1[err] = j;//cun下标
                    cuowu2[cuowu1[err]]++;//存错误次数
                    err++;
                }

            }

            /*if (ss) {
                for (int t = 0; t < count * 2 - 1; t++) {
                    x=random.nextInt(1000);
                    y=random.nextInt(1000);
                    if (2 * left == t) {
                        str += "(";
                        str += String.valueOf(x);
                    }

                    if (t % 2 == 0 && t != count * 2 - 2) {
                        str += String.valueOf(y);
                        if (x % 4 == 1) {
                            str += "+";
                            x=x+y;
                        } else if (x % 4 == 2) {
                            str += "-";
                            x=x-y;
                        } else if (x % 4 == 3) {
                            str += "*";
                            x=x*y;
                        } else if (x % 4 == 0) {
                            str += "/";
                            x=x/y;
                        }

                    }
                    if (2 * right - 2 == t) {
                        str += ")";

                    }else if (t == count * 2 - 2) {
                        str += String.valueOf(x);
                        if (x % 4 == 1) {
                            str += "+";
                            x=x+y;
                        } else if (x % 4 == 2) {
                            str += "-";
                            x=x-y;
                        } else if (x % 4 == 3) {
                            str += "*";
                            x=x*y;
                        } else if (x % 4 == 0) {
                            //System.out.print("/ ");
                            str += "/";
                            x=x/y;
                        }
                        if (2 * right - 2 == t) {
                            str += ")";
                        }
                    }

                }
                //存储题目--计算结果
                str += "=";
                timu[j] = str;
                daanCom[j] = String.valueOf(x);
                System.out.print(str);
                daanPerson[j] = sc.nextLine();
                if (!(daanCom[j].equals(daanPerson[j]))) {
                    cuowu1[err] = j;//cun下标
                    cuowu2[cuowu1[err]]++;//存错误次数
                    err++;
                }
            }*/
        }
    }


        //错题集
        public static void cuoTiJi(int sum) {
            System.out.println("正确率:"+(double)(sum-err)/sum*100.0+"%");
            Scanner sc=new Scanner(System.in);

            for (int i = 0; i < err; i++) {
                System.out.println(timu[cuowu1[i]]);
            }

            System.out.println("请选择是否重做:1、是  2、否");
            int m=sc.nextInt();
            if(m==1) {
                chongZuo();
            }
        }

    public static void chongZuo(){

        Scanner sc=new Scanner(System.in);
        for (int i = 0; i < err; i++) {
            System.out.println(timu[cuowu1[i]]);
            aa[i]=sc.nextLine();
            if(!(aa[i].equals(daanCom[i]))) {
                System.out.println("答错啦!");
            }
        }
    }
    }

最后,祝大家国庆假期快乐吧!!!!反正,我很快乐就是了!!!

标签:纠正,String,错误,int,System,static,测试,new,out
From: https://www.cnblogs.com/liuzijin/p/16745857.html

相关文章

  • 自动化测试中的翻页逻辑
    在许多测试场景中,不免出现需要翻页寻找的元素,在翻页寻找的过程中,需要注意其中的逻辑主要的思维导图: ......
  • 内网速度测试
    目的测试公司地下埋线(网线)是百兆还是千兆 测试方案两台千兆网卡的电脑,A和BA->千兆交换机->埋线B->埋线除埋线外,使用的都是cat6标识的千兆网线。 使用iperf......
  • 四则运算测试二
    packageoperation;importjava.util.Random;importjava.util.Scanner;publicclassoperation{publicstaticintnumber=0;//个数publicstaticintmult=......
  • Linux Centos7.5错误:ping外网报错Name or service not known
    问题描述:1CentOS7.5,当执行pingwww.baidu.com命令时,提示Nameorservicenotknown出现问题可能情况:1、电脑上禁用VMware相关网络服务。2、Linux中网络配置出现了错......
  • PADS应用笔记:Layout怎么检测错误
    问题一边layout结束后要检查是否有问题,那如何启动设计验证呢方法选项栏选择验证设计然后根据需求对相关特性进行验证......
  • 解决问题Linux启动错误“ERROR: There's no '/dev' on rootfs.”不能mount sda2的根文
    在测试KR260的自己工程时,Linux启动报告错误“ERROR:There'sno'/dev'onrootfs.”。对应的工具时PetaLinux2022.1.根文件系统在/dev/sda2,Linux启动后再mount,能成功。......
  • postman 模拟form Post 测试传入List<String>参数方式
    1.postman测试传入List<String>参数方式  http://www.zzvips.com/article/206812.html 2.关于postman的form-data如何传递数组形式 https://blog.csdn.net/chrispaul......
  • 2022 年十大接口测试工具合集
    接口测试的全称是应用程序编程接口(API)测试,从原理上来说,接口测试是模拟客户端向服务器端发送请求,然后检查能否获得正确的返回信息。接口测试用于测试RESTfulAPI、SOAPWeb......
  • 亚马逊攀岩安全带ASTM F1772安全规范测试报告
    亚马逊要求所有发布出售的攀岩绳必须经过检测。必须符合下面列出的特定法规或标准要求:产品名称:ZLR13Ee(威同号)法规或标准要求攀岩绳:EN892:2012+A1:2016(登山装备、动力登山......
  • arcpy报错 \u9519 错误,猜测原因所在
    先上错误图  最近,需要写arcpy的东西,本着能偷懒尽量偷懒的原则,在原来一个上面进行编辑,代码写完,一调试,报\u9519的错误,度娘问了,没什么结果,自己困了三天,还是没结果,后来请......