Skip to content

Instantly share code, notes, and snippets.

@arielmagbanua
Created September 17, 2021 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arielmagbanua/59bd026ac08ac49ad5dbe30c6e2678ed to your computer and use it in GitHub Desktop.
Save arielmagbanua/59bd026ac08ac49ad5dbe30c6e2678ed to your computer and use it in GitHub Desktop.
Draw a Box

Draw a Box

Write a Java program that can draw a box with the given height, width, and character.

Starter Code

public class App {
    public static void main(String[] args) throws Exception {
        // scanner
        Scanner scanner = new Scanner(System.in);

        // get the input height

        // get the input width
        
        // get the character to be used in drawing the box
        
        // print the result

        scanner.close();
    }
}

Output

height: 3
width: 4
character: %

% % % %
% % % %
% % % %
height: 5
width: 3
character: *

* * *
* * *
* * *
* * *
* * *
height: 2
width: 2
character: *

* *
* * 
height: 1
width: 1
character: X

X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment