Guest User

Untitled

a guest
Dec 16th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Rectangle {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int width;
  7. System.out.println("Input width:");
  8. width = sc.nextInt();
  9. int height;
  10. System.out.println("Input height:");
  11. height = sc.nextInt();
  12.  
  13. for (int j = 1; j <= height; j = j + 1) {
  14.  
  15. if ((j == 1) | (j == height)) {
  16.  
  17. for (int i = 1; i <= width; i++) {
  18. System.out.print("*");
  19. }
  20.  
  21. }else {
  22. for (int k = 1; k <= width; k++) {
  23. if ((k==1) | (k == width)) {
  24. System.out.print("*");
  25. }else {
  26. System.out.print(" ");
  27. }
  28. }
  29. }
  30. System.out.println();
  31. }
  32.  
  33. }
  34.  
  35. }
Add Comment
Please, Sign In to add comment