Skip to content

Commit

Permalink
Create JavaStaticInitializerBlock.java
Browse files Browse the repository at this point in the history
  • Loading branch information
debeshp6 authored Nov 16, 2023
1 parent 94ea7c2 commit 9e13571
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions JavaStaticInitializerBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

public static int B,H;
private static boolean flag = false;

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);
}

}//end of main

}//end of class

0 comments on commit 9e13571

Please sign in to comment.