-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtriangle.java
More file actions
34 lines (27 loc) · 831 Bytes
/
triangle.java
File metadata and controls
34 lines (27 loc) · 831 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
// Java program to find the perimeter of a Rectangle
import java.io.*;
class triangle {
// Method to calculate the perimeter of the rectangle
// with given length and breadth
static void perimeter(int length, int breadth)
{
// Calculate the 'perimeter' using the formula
int perimeter = 2 * (length + breadth);
System.out.println("The perimeter of the given rectangle of length "
+ length + " and breadth " + breadth + " = "
+ perimeter);
}
// Driver method
public static void main(String[] args)
{
// Initialize a variable length that stores length of
// the given rectangle
int length = 10;
// Initialize a variable breadth that stores breadth
// of the given rectangle
int breadth = 20;
// Call the perimeter method on these length and
// breadth
perimeter(length, breadth);
}
}