Java Lab3
Java Lab3
class Volume
int width,height,depth,v;
width=w;
height=h;
depth=d;
void volume()
v=width*height*depth;
void display()
class VolumeDemo
ob.volume();
ob.display();
}
}
EXERCISE:-2.1 POLYMORPHISM
class Sharp
void area(float x)
double z=3.14*x*x;
double a;
a=0.5*b*h;
class Area
ob.area(10,10);
ob.area(5.55f);
ob.area(2.5,4.2);
class Overheat
ob.add(9,9);
ob.add(38.2,38.2);
ob.add(321.12,321.12);
ob.mul(4,4);
ob.mul(7.7,7.7);ob.mul(7.482,7.482);
ob.pow(3,6);ob.pow(3.3,6.6);ob.pow(3.32,6.654);
}
POINT CLASS:-
import java.lang.Math.*;
class point
double x,y;
point()
x=0;
y=0;
x=q1;
y=p1;
}
point(point p1)
x=p1.x;
y=p1.y;
double dx=a-x;
double dy=b-y;
point find_distance(point p)
double dx=p.x-x;
double dy=p.y-y;
void display()
System.out.println("("+x+","+y+")");
}
public static void main(String args[])
p3=p2;
k=p1.find_distance(523.45,897.52);
l=p1.find_distance(p3);
k.display();
l.display();