Write a java application that calculate the area of class triangle & circle.(File must be save as: Triangle02.java)
class Circle
{
double r,h;
void area()
{
System.out.print("Redius r= "+r+"\nThe area of the cirle is ");
System.out.println(Math.PI*r*r);
System.out.println();
}
void area1()
{
System.out.print("Arms a= "+h+" b= "+r+"\nThe a rea of the triangle is ");
System.out.println((h*r)/2);
System.out.println();
}
}
class Triangle02
{
public static void main(String args[])
{
Circle b1=new Circle();
Circle b2=new Circle();
Circle b3=new Circle();
Circle b4=new Circle();
b1.r=10;
b2.r=5;
b3.r=5;
b3.h=10;
b4.r=20;
b4.h=5;
b1.area();
b3.area1();
b2.area();
b4.area1();
}
}
////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........