-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstatic_block.java
More file actions
34 lines (30 loc) · 836 Bytes
/
static_block.java
File metadata and controls
34 lines (30 loc) · 836 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
/*
If B<=0 or H<=0, the output should be "java.lang.Exception: Breadth and height must be positive" without quotes.
If both values are greater than zero, then the main method must output the area of the parallelogram. Otherwise, print "java.lang.Exception: Breadth and height must be positive" without quotes.
Platform: HackerRank
*/
import java.io.*;
import java.util.*;
class Static_Block{
static boolean flag = false;
static int B,H;
static{
Scanner sc = new Scanner(System.in);
B = sc.nextInt();
H = sc.nextInt();
if(B>0 && H>0)
{
flag = true;
}
else{
System.out.println("java.lang.Exception: Breadth and height must be positive");
}
}
public static void main(String args[])
{
if(flag){
int area=B*H;
System.out.print(area);
}
}
}