cruz是脾气暴躁的老妖婆 2021-08-27 13:52 采纳率: 90%
浏览 49
已结题

java:如果知道了方法,怎么添加例子

public class Calculator {
    //sum function, return the sum of two given parameters
    public int sum(int numA, int numB){
        return numA + numB;
    }

    //subtraction function, return the subtraction of two given parameters
    public int sub(int numA, int numB){
        return numA - numB;
    }

    //multiplication function, return the multiplication of two given parameters
    public float multiply(float numA, float numB){
        return numA * numB;
    }

    //division function, return the division of two given parameters
    public float division(float numA, float numB){
       
        return numA / numB;
    }
}

如果知道了以上方法,我想输入,比如num的三次方,我该怎么继续写

  • 写回答

5条回答 默认 最新

  • stacksoverflow 2021-08-27 19:07
    关注
    
    public class Calculator {
        //sum function, return the sum of two given parameters
        public int sum(int numA, int numB){
            return numA + numB;
        }
     
        //subtraction function, return the subtraction of two given parameters
        public int sub(int numA, int numB){
            return numA - numB;
        }
     
        //multiplication function, return the multiplication of two given parameters
        public float multiply(float numA, float numB){
            return numA * numB;
        }
     
        //division function, return the division of two given parameters
        public float division(float numA, float numB){
           
            return numA / numB;
        }
        
        public float pow(float numA, float count){
           
            float result = 1;
            for(int i = 0; i < count; i ++) {
                result = result * numA;
            }
            return result;
        }
        
        public float pow3(float numA){
            
            return numA * numA * numA;
        }
        
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

问题事件

  • 系统已结题 10月3日
  • 已采纳回答 9月25日
  • 创建了问题 8月27日

悬赏问题

  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?