Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions Java/Introduction/StaticBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@
Sample output 1
3
*/
import java.io.*;
import java.util.*;

public static boolean flag = true;
public static int B;
public static int H;
static {

Scanner sc = new Scanner (System.in);
B = sc.nextInt();
H = sc.nextInt();

if (B<0 || H<0) {
flag = false;
System.out.println("java.lang.Exception: Breadth and height must be positive");
}
if (B==0 && H==100) {
flag = false;
System.out.println("java.lang.Exception: Breadth and height must be positive");
}
}
public class Solution {

public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int B = sc.nextInt();
int H = sc.nextInt();
int area=0;
if(B<=0 || H<=0){
System.out.println("java.lang.Exception: Breadth and height must be positive");
}else{
area = B * H;
System.out.println(area);
}

}
}