测试3错误纠正

目前仅仅实现了存储题目,存储错题,存储错题个数,无限大,浮点数的计算

但是没有加上乘除和括号(偷偷说一句,好麻烦哦!)

下面是目前的代码,后续会补上没有实现的功能的!

四则运算升级版

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Random;
import java.util.Scanner;

public class Main{
    public static int m=0;//
    static String[] arrError=new String[10000];//存储错题集
    static String[] ALL=new String[10000];//存储题目集
    static String[] answer=new String[10000];//存储计算机的答案
    static String [] getAnswer=new String[10000];//存储输入的答案
    //int error=0;//计算错题个数
    public static int right=0;//计算正确题目的个数

    public static int sum;
    public static int count;
    public static String ff;
    public static int x;
    public static BigInteger b1;

    public static void main(String[] args) {
        while(true) {
            System.out.println("***************");
            System.out.println("1、开始做题");
            System.out.println("2、错题重练");
            System.out.println("3、退出系统");
            System.out.println("***************");
            Scanner sc = new Scanner(System.in);
            int choose = sc.nextInt();
            if (choose == 1) {
                menu();
            } else if (choose == 2) {
                reTest();
            } else if (choose == 3) {
                System.out.println("欢迎下次使用!");
                System.exit(-1);
            } else {
                System.out.println("输入错误!请重新输入:");
            }
        }
    }
    //开始做题
    public static void menu(){
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入你想要打印的题目数量:");
        sum=sc.nextInt();
        System.out.println("请输入操作数的个数:");
        count=sc.nextInt();
        System.out.println("请输入操作数的范围:");
        ff=sc.next();
        System.out.println("请输入是否有乘除法:1、有  2、没有");
        x=sc.nextInt();
        //打印题目
        tiMu(sum,count,ff,x);
    }
    //打印题目集
    public static void tiMu(int sum,int count,String ff,int x){
        Scanner sc=new Scanner(System.in);

        for(int i=0;i<sum;i++){
            String str="";//存储题目集
            //无限大
            b1=new BigInteger(64,new Random());
            //BigDecimal bm=new BigDecimal(ff);
            str+=String.valueOf(b1);
            //float bb=bm.floatValue();
            //浮点数
            //BigDecimal c1=new BigDecimal(Math.random()*bb);
           // str+=String.valueOf(c1);

            for(int j=0;j<count-1;j++){//计算
                 BigInteger b2=new BigInteger(64,new Random());
                //BigDecimal c2=new BigDecimal(Math.random()*bb);
                int choose=(int)(Math.random()*2);
                switch(choose){
                    case 0:
                        str+=" + ";
                        b1=b1.add(b2);
                        //c1=c1.add(c2);
                        break;
                    case 1:
                        str+=" - ";
                        b1=b1.subtract(b2);
                        //c1=c1.subtract(c2);
                        break;
                }
                str+=String.valueOf(b2);
                //str+=String.valueOf(c2);
            }
            str+=" = ";//存储好了一个题目
            ALL[i]=str;
            System.out.println(ALL[i]);
            answer[i]=String.valueOf(b1);//存储好了一个答案
            //answer[i]=String.valueOf(c1);
            String daAn=sc.nextLine();
            getAnswer[i]=daAn;
            if(answer[i].equals(getAnswer[i])){
                right++;
            }
            else{
                arrError[m++]=ALL[i];//存储到错题集当中
            }
        }
        //正确率
        System.out.println("正确率为:"+(100.0*right/sum)+"%");
    }
    //题目重练
    public static void reTest(){
        System.out.println("错题重练界面");
        System.out.println("错题总数为:"+(sum-right));
        System.out.println("---错题集---");
        for(int i=0;i<(sum-right);i++){
            System.out.println(arrError[i]+"  "+answer[i]);
        }
        System.out.println("请自行根据上述内容进行校对和改正!");
    }
}

无限大和浮点数两个功能,可根据上述代码的注释进行代换

乘除法来啦!

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Random;
import java.util.Scanner;

public class Main{
    public static int m=0;//
    static String[] arrError=new String[10000];//存储错题集
    static String[] ALL=new String[10000];//存储题目集
    static String[] answer=new String[10000];//存储计算机的答案
    static String [] getAnswer=new String[10000];//存储输入的答案
    //int error=0;//计算错题个数
    public static int right=0;//计算正确题目的个数

    public static int sum;
    public static int count;
    public static String ff;
    public static int x;
    public static BigInteger b1;

    public static void main(String[] args) {
        while(true) {
            System.out.println("***************");
            System.out.println("1、开始做题");
            System.out.println("2、错题重练");
            System.out.println("3、退出系统");
            System.out.println("***************");
            Scanner sc = new Scanner(System.in);
            int choose = sc.nextInt();
            if (choose == 1) {
                menu();
            } else if (choose == 2) {
                reTest();
            } else if (choose == 3) {
                System.out.println("欢迎下次使用!");
                System.exit(-1);
            } else {
                System.out.println("输入错误!请重新输入:");
            }
        }
    }
    //开始做题
    public static void menu(){
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入你想要打印的题目数量:");
        sum=sc.nextInt();
        System.out.println("请输入操作数的个数:");
        count=sc.nextInt();
        System.out.println("请输入操作数的范围:");
        ff=sc.next();
        System.out.println("请输入是否有乘除法:1、有  2、没有");
        x=sc.nextInt();
        //打印题目
        tiMu(sum,count,ff,x);
    }
    //打印题目集
    public static void tiMu(int sum,int count,String ff,int x){
        Scanner sc=new Scanner(System.in);

        for(int i=0;i<sum;i++){
            String str="";//存储题目集
            //无限大
            b1=new BigInteger(64,new Random());
            //BigDecimal bm=new BigDecimal(ff);
            str+=String.valueOf(b1);
            //float bb=bm.floatValue();
            //浮点数
            //BigDecimal c1=new BigDecimal(Math.random()*bb);
           // str+=String.valueOf(c1);

            for(int j=0;j<count-1;j++){//计算
                 BigInteger b2=new BigInteger(64,new Random());
                //BigDecimal c2=new BigDecimal(Math.random()*bb);
                int choose=(int)(Math.random()*4);
                switch(choose){
                    case 0:
                        str+=" + ";
                        b1=b1.add(b2);
                        //c1=c1.add(c2);
                        break;
                    case 1:
                        str+=" - ";
                        b1=b1.subtract(b2);
                        //c1=c1.subtract(c2);
                        break;
                    case 2:
                        str+=" * ";
                        b1=b1.multiply(b2);
                        //c1=c1.multiply(c2);
                        break;
                    case 3:
                        str+=" / ";
                        b1=b1.divide(b2);
                        //c1=c1.divide(c2);
                        break;
                }
                str+=String.valueOf(b2);
                //str+=String.valueOf(c2);
            }
            str+=" = ";//存储好了一个题目
            ALL[i]=str;
            System.out.println(ALL[i]);
            answer[i]=String.valueOf(b1);//存储好了一个答案
            //answer[i]=String.valueOf(c1);
            String daAn=sc.nextLine();
            getAnswer[i]=daAn;
            if(answer[i].equals(getAnswer[i])){
                right++;
            }
            else{
                arrError[m++]=ALL[i];//存储到错题集当中
            }
        }
        //正确率
        System.out.println("正确率为:"+(100.0*right/sum)+"%");
    }
    //题目重练
    public static void reTest(){
        System.out.println("错题重练界面");
        System.out.println("错题总数为:"+(sum-right));
        System.out.println("---错题集---");
        for(int i=0;i<(sum-right);i++){
            System.out.println(arrError[i]+"  "+answer[i]);
        }
        System.out.println("请自行根据上述内容进行校对和改正!");
    }
}

posted @ 2022-09-17 21:15  yesyes1  阅读(19)  评论(0编辑  收藏  举报