-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloops_o6.java
More file actions
39 lines (31 loc) · 1014 Bytes
/
loops_o6.java
File metadata and controls
39 lines (31 loc) · 1014 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
33
34
35
36
37
38
39
package veckan3loops;
import java.util.Scanner;
import java.util.Random;
public class Veckan3loops_O2 {
/**
* @param args the command line arguments
*/
@SuppressWarnings("empty-statement")
public static void main(String[] args) {
TODO code application logic here
Ovning 6
6. Skapa ett program som "ritar" upp en kvadrat med den storlek som användaren önskar.
Så här kan en programkörning se ut:
Ange sidstorlek på kvadraten:5
[][][][][]
[][][][][]
[][][][][]
[][][][][]
[][][][][]
Scanner input = new Scanner(System.in);
System.out.print("size of cube: ");
int size = input.nextInt();
String symbol = "[]";
for (int x = 0; x <= size-1; x++){
for (int y = 1; y <=size-1; y++){
System.out.print(symbol);
}
System.out.println(symbol);
}
}
}