IPetrov007

Square of stars

Sep 18th, 2016
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class SquarePrint
  5. {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. Scanner input = new Scanner(System.in);
  10. int num = input.nextInt();
  11. String a = "*";
  12. String b = " ";
  13.  
  14. for (int i = 1; i <= num; i++) {
  15. System.out.print(a);
  16. }
  17. System.out.print('\n');
  18.  
  19.  
  20. for (int x = 1; x <= (num - 2); x++) {
  21. System.out.print(a);
  22.  
  23. for (int y = 1; y <= (num - 2); y++) {
  24. System.out.print(b);
  25. }
  26. System.out.println(a);
  27. }
  28.  
  29. for (int i = 1; i <= num; i++) {
  30. System.out.print(a);
  31. }
  32. System.out.print('\n');
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment