zoukankan      html  css  js  c++  java
  • 测试5.2

    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;
                }
            }
        }
    }
    

      

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

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

  • 相关阅读:
    AttributeError: 'DatabaseFeatures' object has no attribute 'autocommits_when_autocommit_is_off'
    mac 添加adb环境变量
    ios环境搭建
    接口自动化测试平台介绍
    听风系统介绍
    nginx启动报错整理
    Mongodb: Sort operation used more than the maximum 33554432 bytes of RAM
    Mac上python 在终端使用pip3安装包报ConnectTimeoutError错误
    crontab -让服务器执行定时任务
    koajs项目之memcached实现session共享
  • 原文地址:https://www.cnblogs.com/zengwei35/p/4488637.html
Copyright © 2011-2022 走看看