當前位置:編程學習大全網 - 電腦編程 - 怎麽用JAVA語言編寫加減乘除取余

怎麽用JAVA語言編寫加減乘除取余

public int add(int a,int b){

return a+b;

}

public int subtraction(int a,int b){

return a-b;

}

public int multiply(int a,int b){

return a*b;

}

public int division(int a,int b){

if(b!=0){

return a/b;

}else{

return -1;

}

}

public int yu(int a,int b){

if(b!=0){

return a%b;

}else{

return -2;

}

}

主函數調用,僅供參考!

  • 上一篇:計算20編程
  • 下一篇:C#編程switch壹個很簡單的問題,我這樣為什麽錯了,搞不懂啊
  • copyright 2024編程學習大全網