• 作业五——封装


    public class test {
        private int a;
        private int b;
        int c;
        public int  add(int a,int b)
        {
        
            System.out.println(""+a);
            System.out.println(""+b);
            c = a+b;
            System.out.println("a+b="+(a+b)+"
    ");
            return c;
            
        }
        public int  jian(int a,int b)
        {
            
            System.out.println(""+a);
            System.out.println(""+b);
            c=a-b;
            System.out.println("a-b="+(a-b)+"
    ");
            return c;
            
            
        }
        public int Cheng(int a,int b)
        {   
            System.out.println(""+a);
            System.out.println(""+b);
            c=a*b;
            System.out.println("a*b="+(a*b)+"
    ");
            return c;
        }
        public double  Chu(int a,int b)
        {
            double c;
            c=(double) (Math.round((a/b)*100/100.0));
            System.out.println(""+a);
            System.out.println(""+b);
            if(b!=0)
                System.out.println("c=a/b="+(c)+"
    ");
            else
                throw new ArithmeticException();
                System.out.println("分母不能为0!");
                  
                return c;
        }
    
        /**
         * @param args
         */
        public static void main(String[] args) {
             Test Jia=new Test();
             Jia.jia(1, 1);
             Test Jian=new Test();
             Jian.jian(2,1);
             Test cheng=new Test();
             cheng.Cheng(2,3);
             Test chu=new Test();
             chu.Chu(3,0);
             
        }
    我和我的小伙伴共同研究出来的代码!真的是涨知识了啊~.~
  • 相关阅读:
    MySQL分库分表环境下全局ID生成方案
    centos添加php及mysql环境变量
    shell中的常用通配符,字符类
    centos7 安装xinetd,telnet
    centos7 systemctl一些用法
    ps命令
    nginx与php-fpm通信的两种方式
    nginx常用功能
    MySQL安装
    MySql与MariaDB由来与历程
  • 原文地址:https://www.cnblogs.com/Oliver-zzc/p/4469517.html
Copyright © 2020-2023  润新知