Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Design a multiplication class with java
Design a multiplication class with java
Common class multiplication {

/* Calculate the product of two integers */

public int mul(int i,int j) {

Return I * j;;

}

/* Calculate the product of two floating-point numbers */

Public double mul(double x, double y) {

Returns x * y;;

}

/* Calculate the product of three floating-point numbers */

Public double mul(double x, double y, double z) {

Returns x * y * z;;

}

}

……………………………………………………………………………………………

Import java.applet.applet;

Import java.awt.graphics;

/* Test and output classes */

Common class test extension applet {

Private strings re 1, re2, re3

public void init() {

Multiplication m = new multiplication ();

Re 1 = (new integer (m.mul (3,4))). toString();

re2 = (new Double(m.mul(3.3,4.3)))。 toString();

re3 = (new Double(m.mul(3.3,4.3,5.3)))。 toString();

}

Public blank paint (figure g)

G. drawing (re 1,100,80);

G. draw rope (re2, 100,100);

G. drawing tape (re3, 100,120);

}

}