Advertisement
pavsavov

Drawing Figures with Loop

Feb 15th, 2017
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class SquareFrame {
  5.  
  6. public static void main(String [] args){
  7. Scanner scanner = new Scanner(System.in);
  8. int n = Integer.parseInt(scanner.nextLine());
  9. // -----------------------
  10. System.out.print("+ ");
  11. for(int i=0 ; i<n-2; i++){
  12. System.out.print("- ");
  13. }
  14. System.out.println("+");
  15. // -----------------------
  16. for(int i=0 ; i<n-2; i++){
  17. System.out.print("| ");
  18. for(int j =0 ; j<n-2; j++){
  19. System.out.print("- ");
  20. }
  21. System.out.println("| ");
  22. }
  23. // -----------------------
  24. System.out.print("+ ");
  25. for(int i=0 ; i<n-2; i++){
  26. System.out.print("- ");
  27. }
  28. System.out.print("+");
  29.  
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement