Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Scanner teclado = new Scanner(System.in);
  2. System.out.println("Introduce el tamaño del cuadrado: ");
  3. int n = teclado.nextInt();
  4.  
  5. if(n >= 0 )
  6. { //linea superior
  7. for(int i = 0; i < n; i++);
  8. {
  9. System.out.println("*");
  10. }
  11. System.out.println();
  12. //centro
  13. for(int i=0; i<n-2; i++);
  14. {
  15. System.out.println("*");
  16. for(int j = 0; j < n-2; j++)
  17. {
  18. System.out.println(" ");
  19. }
  20. System.out.println("*");
  21. }
  22.  
  23.  
  24. //linea inferior
  25. for(int i = 0; i < n; i++);
  26. {
  27. System.out.println("*");
  28. }
  29. }
  30. else
  31. {
  32. System.out.println("tampoco te flipes y mete un numero positivo");
  33. }
  34.  
  35.  
  36.  
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement