HowdoIcreatethisinnetbeans? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2
ID: 640304 • Letter: H
Question
HowdoIcreatethisinnetbeans?
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 66 67 68 69 70 71 72
73 74 75 76 77 78 79
80 81 82 83 84 85
86 87 88 89 90
91 92 93 94
95 96 97
98 99
100
Hints:
Examine the top half of the half:
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
There are 10 rows (outer loop)
The number of leading space blocks (2 spaces per block) is a function of the row number in reverse (e.g. 9, 8,
HowdoIcreatethisinnetbeans?
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 66 67 68 69 70 71 72
73 74 75 76 77 78 79
80 81 82 83 84 85
86 87 88 89 90
91 92 93 94
95 96 97
98 99
100
Hints:
- Consider splitting the problem into two parts: One set of loops for the top half of the diamond, and another set for the bottom part of the diamond
- An outer loop can be used to control the printing for each row
- The outer loop can contain two inner loops: one to control printing the leading spaces, and another to control the printing of the digits
- Use printf statements to control the spacing in the digit display
Examine the top half of the half:
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
There are 10 rows (outer loop)
The number of leading space blocks (2 spaces per block) is a function of the row number in reverse (e.g. 9, 8,
Explanation / Answer
int i,j,k=1;
for(i=1;i<=11;i++)
{
System.out.println();
for (j=11; i<j; j--)
{
System.out.println(
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.