Advertisement
galinyotsev123

ProgBasicsJavaBook1.0FirstSteps6SquareOfStars

Jan 25th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SquareofStars {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int n = Integer.parseInt(scan.nextLine());
  7.  
  8. String stars = new String(new char[n]).replace("\0", "*");
  9. System.out.println(stars);
  10.  
  11. for (int i = 0; i < n - 2; i++) {
  12. System.out.printf("*");
  13. System.out.printf(new String(new char[n - 2]).replace("\0"," "));
  14. System.out.println("*");
  15.  
  16. }
  17.  
  18. System.out.println(stars);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement