zoukankan      html  css  js  c++  java
  • 软件工程个人作业01(2)

    增加了验证的功能,其他功能待续……

        public static char yunsuan;
        public static int a;
        public static int b;
        public static int result;
        
        public char getyunsuan() {
            return yunsuan;
        }
        public int geta() {
            return a;
        }
        public int getb() {
            return b;
        }
        
        public static void main(String[] args)
        {
         
            for(int i=0;i<30;i++){    //for循环定义题目数量
                char [] fu = new char [4];
                fu[0] = '/';
                fu[1] = '+';
                fu[2] = '-';
                fu[3] = '*';
                yunsuan=fu[new Random().nextInt(4)];
                a= new Random().nextInt(100) + 1;
                b= new Random().nextInt(100) + 1;
            
                if(yunsuan=='+')
                    result=a+b;
                else if(yunsuan== '-')
                    result=a-b;
                else if(yunsuan=='*')
                    result=a*b;
                else
                    result=a/b;
            }
        }
        
        @SuppressWarnings("resource")
        public String yanzheng() {
            
            System.out.print(a+ " "+yunsuan+ " " + b+ " = ");
            int str = new Scanner(System.in).nextInt();
            if(str == result)
                return "回答正确";
            else
                return "错误,正确答案为"+result;
        }
    }
  • 相关阅读:
    Oracle数据库5--数据库对象
    Oracle数据库4--多表关联
    Session
    cookie
    Servlet的部分response响应处理
    Servlet的部分request请求处理
    Linux部分命令
    Linux基础
    弹性布局
    animation 动画
  • 原文地址:https://www.cnblogs.com/lzxw/p/6492294.html
Copyright © 2011-2022 走看看