/* related posts with thumb nails */

Create a package called “Arithmetic” that contains methods to deal with all arithmetic operations. Also, write a program to use the package.:

Note: First create a directory by name “Arithmetic” and move to that directory, create the following file and compile the file in the same directory.

package arithmetic;

public class MyMath

{

public int add(int x,int y)

{

return x+y;

}

public int sub(int x,int y)

{

return x-y;

}

public int mul(int x,int y)

{

return x*y;

}

public double div(int x,int y)

{

return (double)x/y;

}

public int mod(int x,int y)

{

return x%y;

}

}

Note: Move to parent directory, write the following file and execute it.

import arithmetic.*;

class Test

{

public static void main(String as[])

{

MyMath m=new MyMath();

System.out.println(m.add(8,5));

System.out.println(m.sub(8,5));

System.out.println(m.mul(8,5));

System.out.println(m.div(8,5));

System.out.println(m.mod(8,5));

}

}

/* Output: */

13

3

40

1.6

3

Related Topics:

4 comments:

Unknown said...

What are the steps to compile this program

Unknown said...

Showing this program errror inonline gdb in the line import. Arthematic. *

Charlotte27 said...

thanks

Charlotte27 said...

China Polyester Films are used for packaging as well as solvent-based coating applications. These films are commonly defined for packaged labels, concealing applications, design illustrations, as well as face shields.

Post a Comment