Question: Write the method public int sumRow(int[][] matrix, int row) that sums row row in the 2D array called matrix. Exercise 5.7.4: Ice Cream Combos Youre

Write the method

public int sumRow(int[][] matrix, int row)

that sums row row in the 2D array called matrix.

Exercise 5.7.4: Ice Cream Combos

Youre at the ice cream store trying to decide what kind of ice cream and toppings you want. There are so many choices!

You decide to write a program to help you list out every possible choice.

Write a method

ArrayList getAllChoices(String[] flavors, String[] toppings)

That takes an array of ice cream flavors and an array of toppings as parameters, and returns an ArrayList holding every possible combination of ice cream and toppings.

Each combination should be represented in the form

"{{flavor}} with {{topping}} on top"

Where {{flavor}} is a provided flavor of ice cream, like chocolate, and {{topping}} is a provided topping, like sprinkles.

For example, the method call:

String[] flavors = {"chocolate", "vanilla"};

String[] toppings = {"sprinkles", "fudge"};

getAllChoices(flavors, toppings);

Should return an ArrayList holding the following Strings:

["chocolate with sprinkles on top", "chocolate with fudge on top", "vanilla with sprinkles on top", "vanilla with fudge on top"]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!