-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSquare.java
56 lines (41 loc) · 1.11 KB
/
Square.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
import java.util.Scanner;
public class Square {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter how big u want ur square to be");
int size;
size = input.nextInt();
int counter1;
int counter2;
int counter3;
int counter4;
counter1 = 0;
counter2 = 0;
counter3 = 0;
counter4 = 0;
//https://classroom.google.com/u/1/c/NzA1NDAxNDQ2NjAx/m/NzA1NDAxNDQ2NzI3/details
while (counter2 <= size - 1) {
counter2++;
System.out.printf("* ");
}
System.out.printf("\n");
while (counter4 <= size - 3) {
counter4++;
System.out.printf("* ");
while (counter1 <= size - 3) {
counter1++;
System.out.printf(" ");
}
counter1=0;
System.out.printf("*\n");
}
while (counter3 <= size - 1) {
System.out.printf("* ");
counter3++;
}
} //ok so the general algorithm is: print 5 asterisks
//Jump to a new line
///Print 1 asterisk on the new line
//print size-2 spaces after the new line with 1 asterisk on the left
//print 1 asterisk, now on the very right of the space, then skip to the new line and repeat
}