#cornerSum()

1 messages · Page 1 of 1 (latest)

median crown
#

I need help with the cornerSum() method. Essentially, it adds the 4 corners of the 2 dimensional array square. I don't know how to add the 4 corners. The side of the square is instantiated through the user's input from another method so I cannot depend on me knowing the indexes to the corners.

fading plazaBOT
#

<@&987246717831381062> please have a look, thanks.

fading plazaBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

fresh sentinel
#

Do you mean something like this?

#
int topLeftCorner = arr[0][0];
int topRightCorner = arr[0][arr.length];
int bottomLeftCorner = arr[arr.length-1][0];
int bottomRightCorner = arr[arr.length-1][(arr[arr.length-1]).length-1];
int cornerSum = topLeftCorner + topRightCorner + bottomLeftCorner + bottomRightCorner;