Write a java program to find the area for the following :1)area of rhombus =1/2*diagonal1* diagonal 2. 2)areaof trapezium =1/2*height *(a+b) .3)area of circle =pie*r*r.
Answers
1. Area of Rhombus
public class area
{
public static void main(String args[])
{
int d1 = 12;
int d2 = 13;
int area = 1/2*d1*d2;
System.out.println("The area of rhombus="+area);
}
}
2. Area of trapezium
public class trapezium
{
public static void main(String args[])
{
int h = 10;
int a = 5;
int b = 6;
int area = 1/2*h*(a+b);
System.out.println("The area of trapezium="+area);
}
}
3. Area of circle
public class circle
{
public static void main(String args[])
{
int r = 7;
double pie = 3.14;
double area = 3.14*r*r;
System.out.println("The area of circle="+area);
}
}
Hope this answer will help you!!❤✌
please mention the methods also as there are many ways to run a java program.
I have used the simplest method hope it helps!!❤✌
import java.util.*;
public class Area
{
public static void main (String args[])
{
Scanner in= new scanner (System.in);
int d1,d2, h, a , b, rd;
double r, t, c;
System.out.println("enter the values of the diagonals of rhombus, the values of the parallel sides and height of trapezium and the radius of the circle :");
d1 = in.nextInt();
d2 = in.nextInt();
h = in.nextInt();
a = in.nextInt();
b = in.nextInt();
rd = in.nextInt();
r = (1/2*d1*d2);
t = (1/2*h*(a+b));
c = (22/7*r*r);
System.out.println("Area of rhombus = " +r );
System.out.println("Area of trapezium =" +t );
System.out.println("Area of circle =" +c);
}
}