學習利用java編寫簡單的乘法運算
阿新 • • 發佈:2018-12-23
package kll;
public class hys {
public hys(){
System.out.println(“兩數相乘求積:”);
}
public void mul(int x,int y){
System.out.println(“求兩個整數:”+x+”*”+y+”=”+x*y);
} public void mul(int x,float z){ System.out.println("一個菱形、一個單精度浮點數:"+x+"*"+z+"="+x*z); } public void mul(float x,float z){ System.out.println("兩個單精度浮點數:"+x+"*"+z+"="+x*z); } public static void main(String[] args) { // TODO 自動生成的方法存根 hys y=new hys(); y.mul(3,2); y.mul(3, 3.5f); y.mul(3.0f, 2.5f); }
}
執行結果如下圖所示