-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAreaOf_usingMethod.java
More file actions
46 lines (39 loc) · 1 KB
/
Copy pathAreaOf_usingMethod.java
File metadata and controls
46 lines (39 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package Examples;
import java.util.Scanner;
public class AreaOf_usingMethod {
public static void main (String[] args)
{
float r;
int a,l;
double h,b;
System.out.print("Enter Radius of circle:");
Scanner input = new Scanner(System.in);
r = input.nextFloat();
System.out.println("Area of Circle= "+area(r,3.142f));
System.out.print("\nEnter Height of the Triangle: ");
h=input.nextDouble();
System.out.print("Enter Base of the Triangle: ");
b=input.nextDouble();
System.out.println("Area of Triangle= "+area(h,b));
System.out.print("\nEnter length of the rectangle:");
l = input.nextInt();
System.out.print("Enter width of the rectangle:");
a = input.nextInt();
System.out.println("Area of Rectangle= "+area(a,l));
}
public static float area(float a,float pi)
{
float ar = pi*a*a;
return ar;
}
public static double area(double h,double b)
{
double ar = h*b/2;
return ar;
}
public static int area(int a, int l)
{
int x = a*l;
return x;
}
}