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
4 comments:
What are the steps to compile this program
Showing this program errror inonline gdb in the line import. Arthematic. *
thanks
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