-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainSquare2.java
More file actions
22 lines (22 loc) · 823 Bytes
/
Copy pathMainSquare2.java
File metadata and controls
22 lines (22 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
class Rectangle{
private double length; private double breadth;
public Rectangle(double length, double breadth){
this.length=length;
this.breadth=breadth;
}
public static double CalculateArea(double length, double breadth){
return length*breadth;
}
}
public class MainRectangle{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("Enter the value of the length : ");
double x = sc.nextDouble();
System.out.print("Enter the value of the breadth : ");
double y = sc.nextDouble();
System.out.print("\n Calculating...\n");
System.out.printf("The Area of the Rectangle with length %f and breadth %f is : %f",x,y,Rectangle.CalculateArea(x,y));
}
}