import java.util.*;
public class 四则运算 {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int a,b;
        Scanner sc = new Scanner(System.in);
        //int Max=4;
        //int min=1;
        //Random random=new Random();
        //int s=random.nextInt(Max)%(Max-min+1)+min;
        System.out.println("请输入你的题量;");
        int c=sc.nextInt();
        for(int i=0;i<c;i++)
        {
        int s=1+(int)(Math.random()*4);
        switch(s)
        {
        case 1:
                int k;
                a=1+(int)(Math.random()*100);
                b=1+(int)(Math.random()*100);
                System.out.println(a+"+"+ b + "=");
                k=sc.nextInt();
                if(k==a+b)
                    System.out.println("答案正确;");
                else System.out.println("答案错误,正确答案为"+(a+b));   
                break;
        case 2:
            int l=0;
            a=1+(int)(Math.random()*100);
            b=1+(int)(Math.random()*100);
            System.out.println(a+"-"+ b + "=");
            l=sc.nextInt();
            if(l==a-b)
            {
                System.out.println("答案正确;");
                if(a<b)
                    System.out.println("改答案为负数;");
            }
            else System.out.println("答案错误,正确答案为"+(a-b));   
            break;
        case 3:
            int m;
            a=1+(int)(Math.random()*10);
            b=1+(int)(Math.random()*10);
            System.out.println(a+"*"+ b + "=");
            m=sc.nextInt();
            if(m==a*b)
                System.out.println("答案正确;");
            else System.out.println("答案错误,正确答案为"+(a*b));   
            break;
        case 4:
                int n;
                a=1+(int)(Math.random()*30);
                b=1+(int)(Math.random()*30);
                System.out.println(a+"/"+ b + "=");
                n=sc.nextInt();
                if(n==a/b)
                    System.out.println("答案正确;");
                else System.out.println("答案错误,正确答案为"+(a/b));   
                break;
            }
        }
    }
}

  测试5.2

感想:对这个黑盒测试的功能,其实也是蛮简单的,难度不高,但是也是花了一些时间去弄懂,问同学。

虽然他们都有队友了,但还是没有抛弃我,一直教我。

相关文章:

  • 2021-05-19
  • 2021-11-17
  • 2021-11-14
  • 2021-12-10
  • 2021-09-24
  • 2021-10-30
  • 2021-07-12
  • 2021-11-09
猜你喜欢
  • 2021-11-13
  • 2022-03-02
  • 2021-11-09
  • 2021-08-06
  • 2022-01-13
  • 2021-07-24
  • 2021-11-13
相关资源
相似解决方案