今天寫了個乘積運算函數,小筆記錄一下:
public class Multiplier {
public int multiply(int x, int y) {
int total = 0;
//11*16相當於11個16相加
for (int i = 0; i < x; i++){
total += y;
System.out.println(total);
}
return total;
}
public static void main(String[] args) {
Multiplier m = new Multiplier();
System.out.println("11*16 = " + m.multiply(11, 16));
}
}