id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

simona1@sfusd.edu two_d_arrays > add
prev  |  next  |  chance

Write a method named add that returns a string representation of a two-dimensional array of int. The first and second parameters are Strings that represent rectangular two dimensional arrays of ints, representing matrices. Convert them to two dimensional arrays with method toArray(). The resultant array should be the matrix sum: same size, and each element should be the sum of the coresponding elements in the parameters. If the arrays are different sizes, return the string "impossible". Build the array in this method, then use toString() to return the array as a string. You must cut and paste methods toString() and toArray() from the Hint.


add("{{2}}", "{{3}}") → "{{5}}"
add("{{}}", "{{}}") → "{{},{}}"
add("{{}}", "{{3}}") → "impossible"

...Save, Compile, Run (ctrl-enter)

public String add(String as, String bs) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 335 Post-solution available

Copyright Nick Parlante 2017 - privacy