From 9d53d8857eaa1c9405894a88ca75bc4657e42f35 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 05:31:48 -0600 Subject: Inital Commit --- Java/HollowBox.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Java/HollowBox.java (limited to 'Java/HollowBox.java') diff --git a/Java/HollowBox.java b/Java/HollowBox.java new file mode 100644 index 0000000..64bb43d --- /dev/null +++ b/Java/HollowBox.java @@ -0,0 +1,52 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; + +class HollowBox { + public static void main(String[] args) throws java.io.IOException { + int h,w; + //Buffered readers can improve speed up to 30% as they are less bloated than scanners and don't cause a memory leak when not closed + BufferedReader HeightI = new BufferedReader(new InputStreamReader(System.in)); + BufferedReader WidthI = new BufferedReader(new InputStreamReader(System.in)); + System.out.println("Height"); + h = Integer.parseInt(HeightI.readLine()); + System.out.println("Width"); + w = Integer.parseInt(WidthI.readLine()); + + +//if less than 3, re-enter +if(h<3) { +System.out.println("Invalid height! Re-enter:"); +h = Integer.parseInt(HeightI.readLine()); + +} + +if(w<3) { +System.out.println("Invalid width! Re-enter:"); +w = Integer.parseInt(WidthI.readLine());; +} + + +for(int i=0;i