-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsete.java
More file actions
32 lines (24 loc) · 821 Bytes
/
sete.java
File metadata and controls
32 lines (24 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.Scanner;
public class sete {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int lado;
do {
System.out.print("Digite o tamanho do lado do quadrado (entre 1 e 20): ");
lado = scanner.nextInt();
if (lado < 1 || lado > 20) {
System.out.println("O tamanho do lado deve estar entre 1 e 20.");
}
} while (lado < 1 || lado > 20);
imprimirQuadrado(lado);
scanner.close();
}
public static void imprimirQuadrado(int lado) {
for (int i = 0; i < lado; i++) {
for (int j = 0; j < lado; j++) {
System.out.print("*");
}
System.out.println();
}
}
}