File: /home/student/saiesh/ADS/Assignment No 13/ads13_2A.java
package pack;
interface ip
{
public
public
public
public
}
void
void
void
void
add(int
sub(int
mul(int
div(int
a,
a,
a,
a,
int
int
int
int
b);
b);
b);
b);
public class A implements ip
{
public void add(int a, int b)
{
System.out.println("Addition is\t\t: "+(a+b));
}
public void sub(int a,int b)
{
System.out.println("Substraction is\t\t: "+(a-b));
}
public void mul(int a, int b)
{
System.out.println("Multiplication is\t: "+(a*b));
}
public void div(int a, int b)
{
System.out.println("Division is\t\t: "+(a/b));
}
}
Page 1 of 1
.......................
File: /home/student/saiesh/ADS/Assignment No 13/ads13_2B.java
package mypack;
import pack.*;
import java.util.Scanner;
public class B
{
public static void main(String arg[])
{
A obj= new A();
Scanner sc=new Scanner(System.in);
System.out.println("\nEnter first number\t: ");
int a=sc.nextInt();
System.out.println("\nEnter second number\t: ");
int b=sc.nextInt();
obj.add(a,b);
obj.sub(a,b);
obj.mul(a,b);
obj.div(a,b);
}
}
/*
OUTPUT
[saiesh@saiesh ~]$ javac -d . A.java
[saiesh@saiesh ~]$ javac -d . B.java
[saiesh@saiesh ~]$ java mypack.B
Enter first number
: 5
Enter second number
: 5
Addition is
Substraction is
Multiplication is
Division is
[saiesh@saiesh ~]$ */
:
:
:
:
10
0
25
1
Page 1 of 1
package pack;
interface ip
{
public
public
public
public
}
void
void
void
void
add(int
sub(int
mul(int
div(int
a,
a,
a,
a,
int
int
int
int
b);
b);
b);
b);
public class A implements ip
{
public void add(int a, int b)
{
System.out.println("Addition is\t\t: "+(a+b));
}
public void sub(int a,int b)
{
System.out.println("Substraction is\t\t: "+(a-b));
}
public void mul(int a, int b)
{
System.out.println("Multiplication is\t: "+(a*b));
}
public void div(int a, int b)
{
System.out.println("Division is\t\t: "+(a/b));
}
}
Page 1 of 1
.......................
File: /home/student/saiesh/ADS/Assignment No 13/ads13_2B.java
package mypack;
import pack.*;
import java.util.Scanner;
public class B
{
public static void main(String arg[])
{
A obj= new A();
Scanner sc=new Scanner(System.in);
System.out.println("\nEnter first number\t: ");
int a=sc.nextInt();
System.out.println("\nEnter second number\t: ");
int b=sc.nextInt();
obj.add(a,b);
obj.sub(a,b);
obj.mul(a,b);
obj.div(a,b);
}
}
/*
OUTPUT
[saiesh@saiesh ~]$ javac -d . A.java
[saiesh@saiesh ~]$ javac -d . B.java
[saiesh@saiesh ~]$ java mypack.B
Enter first number
: 5
Enter second number
: 5
Addition is
Substraction is
Multiplication is
Division is
[saiesh@saiesh ~]$ */
:
:
:
:
10
0
25
1
Page 1 of 1
Comments
Post a Comment