Yes, something like that. The variable name k is a bit obscure: k??? instead of nbrOfRows that describes what is in it.
Type: Posts; User: Norm
Yes, something like that. The variable name k is a bit obscure: k??? instead of nbrOfRows that describes what is in it.
Replace the numbers 4 and 5 with variables. Don't hard code numbers in the code.
Then write a method that takes the number of rows as its arg.
Call the method with different values for the number...
All the 5s and 4s should be replaced by variables. The 2 is ok because it is used to get half of a value and would never change.
You could Wrap the post of the output in code tags to preserve the leading spaces so we can see its shape.
Glad you solved it.
Note: The code has too many "magic numbers". Can you change it so...
Can you describe the pattern of the desired output:
how many lines are printed?
what goes on each line?
How does what is printed on a line relate to what line is being printed?
Can you post the program's current output to show what it does?
Describe the pattern of the output:
how many lines are printed?
what goes on each line?