import java.util.Scanner;
class circle
{
int r;
double area()
{
return r*r;
}
double dia_circle()
{
return 2*r;
}
}
class rectangle
{
int l,w;
rectangle(int x,int y)
{
l=x;
w=y;
}
double area()
{
return l*w;
}
}
public class Circle_rect_object {
public static void main(String[] args) {
Scanner virus=new Scanner(System.in);
circle c1=new circle();
circle c2=new circle();
System.out.println("enter the radius for c1");
c1.r=virus.nextInt();
System.out.println("enter the radius for c2");
c2.r=virus.nextInt();
System.out.println("area of c1 is "+c1.area()+" area of c2 is "+c2.area());
System.out.println("diameter of c1 "+c1.dia_circle()+" diameter of c2 "+c2.dia_circle());
System.out.println("enter hight and width of rectangle");
int x=virus.nextInt();
int y=virus.nextInt();
rectangle r=new rectangle(x,y);
System.out.println("the area of rectangle is "+r.area());
}
}
class circle
{
int r;
double area()
{
return r*r;
}
double dia_circle()
{
return 2*r;
}
}
class rectangle
{
int l,w;
rectangle(int x,int y)
{
l=x;
w=y;
}
double area()
{
return l*w;
}
}
public class Circle_rect_object {
public static void main(String[] args) {
Scanner virus=new Scanner(System.in);
circle c1=new circle();
circle c2=new circle();
System.out.println("enter the radius for c1");
c1.r=virus.nextInt();
System.out.println("enter the radius for c2");
c2.r=virus.nextInt();
System.out.println("area of c1 is "+c1.area()+" area of c2 is "+c2.area());
System.out.println("diameter of c1 "+c1.dia_circle()+" diameter of c2 "+c2.dia_circle());
System.out.println("enter hight and width of rectangle");
int x=virus.nextInt();
int y=virus.nextInt();
rectangle r=new rectangle(x,y);
System.out.println("the area of rectangle is "+r.area());
}
}
No comments:
Post a Comment