Advertisement
MilaDimitrovaa

Фигурка с метод

Oct 14th, 2020
1,182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package metodi;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class metodiii {
  6.  
  7.     public static void top (int n ) {
  8.        
  9.         System.out.print("+");
  10.         for( int i = 0 ; i < n - 2 ; i++ ) {
  11.         System.out.print("-");
  12.     }
  13.        System.out.println("+");
  14.     }
  15.        public static void mid (int n ) {
  16.  
  17.            for (int i  = 0 ; i < n - 2 ; i++) {
  18.                System.out.print("|");
  19.              for ( int j = 0 ; j < n - 2 ; j++) {
  20.                  System.out.print("-");
  21.              }
  22.                System.out.println("|");
  23.      
  24.            }  
  25.        }
  26.            public static void main(String[] args) {
  27.                 Scanner scan = new Scanner(System.in);
  28.                
  29.                 int n = scan.nextInt();
  30.                
  31.                 top(n);
  32.                 mid(n);
  33.                 top(n);
  34.                
  35.            }
  36.    
  37.  
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement