Advertisement
Atheuz

Untitled

Mar 27th, 2011
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. package drawbox;
  2. public class Main {
  3. public static int height;
  4. public static int length;
  5. public static void main(String[] args) {
  6. drawBox(10, 50);
  7. }
  8. public static void drawBox(int height, int length) {
  9. for (int i = 0; i <= height; i++) {
  10. if (i == 0 || i == height) {
  11. startEndLines();
  12. } else if ((i > 0) && (i < height)) {
  13. System.out.print("|");
  14. for (int j = 1; j < length; j++) {
  15. System.out.print(" ");
  16. }
  17. System.out.println("|");
  18. }
  19. }
  20. }
  21. public static void startEndLines() {
  22. for (int i = 0; i <= length; i++) {
  23. if (i == 0) {
  24. System.out.print("*");
  25. } else if (i == length) {
  26. System.out.println("*");
  27. } else {
  28. System.out.print("-");
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement