-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ejercicio19.java
65 lines (53 loc) · 1.71 KB
/
Ejercicio19.java
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
Ejercicio # 19
Dibujar un cuadrado de N elementos por lado utilizando el carácter “*”. Por ejemplo,
si el cuadrado tiene 4 elementos por lado se deberá dibujar lo siguiente:
* * * *
* *
* *
* * * *
*
*/
package egg_ejercicios;
import java.util.Scanner;
/**
*
* @author WALTER GOMEZ
*/
public class Ejercicio19 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner leer = new Scanner(System.in).useDelimiter("\n");
//DecimalFormat df = new DecimalFormat("###.##");
LlenarMatriz();
}
public static void LlenarMatriz (){
Scanner leer = new Scanner(System.in).useDelimiter("\n");
int c;
System.out.println("Ingrese el tamaño del cuadrado a dibujar ");
System.out.println("recuerde que el valor no debe ser superior a 10 ");
c=leer.nextInt();
if(c >= 0 && c<=10) {
for(int i = 0; i < c; i++) {
System.out.print("*");
}
System.out.println();
for(int i = 0; i < c-2; i++) {
System.out.print("*");
for(int j = 0; j < c-2; j++) {
System.out.print(" ");
}
System.out.println("*");
}
for(int i = 0; i < c; i++) {
System.out.print("*");
}
}else {
System.out.println("Error,El dato a ingresar de "
+ "estar entre 0 y 10");
}
System.out.println("\n");
}
}