-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAreaRectCircle.java
More file actions
39 lines (26 loc) · 894 Bytes
/
Copy pathAreaRectCircle.java
File metadata and controls
39 lines (26 loc) · 894 Bytes
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
import java.util.Scanner;
public class AreaRectCircle
{
void Area(double x,double y){
String area=String.format("%.3f", (x*y));
System.out.println("Area of Rectange is "+area+" sq.units");
}
void Area(double x){
double pi = 3.1415;
String area= String.format("%.3f", (pi*x*x));
System.out.println("Area of Circle is "+area+" sq.units");
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double radius,length,breadth;
System.out.println("Enter radius of circle :");
radius =sc.nextDouble();
AreaRectCircle circle = new AreaRectCircle();
circle.Area(radius);
System.out.println("Enter length and beadth of rectangle :");
length = sc.nextDouble();
breadth = sc.nextDouble();
AreaRectCircle rectangle = new AreaRectCircle();
rectangle.Area(length, breadth);
}
}