Design a class to find area of parameter of circle and also used the class in main method in java
class Test{
int r;
void set(int radius){
r=radius;
}
double area(){
double a= 3.14*r*r;
return a;
}
double parameter(){
return (2*3.14*r);
}
}
class Main{
public static void main(String args[]){
Test obj=new Test();
int r=5;
obj.set(r);
double a=obj.area();
double p=obj.parameter();
System.out.println("Circle area "+a);
System.out.println("Circle of Parameter "+p);
}
}
0 Comments