Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2 . 9 . 4 Ice Cream Combos You re at the ice cream store trying to decide what kind of ice cream and

Exercise 2.9.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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Question What is a secular trust?

Answered: 1 week ago