Problem 1: Array basics
Task 1: Printing
We’ve created an array of existing restaurants in our system! We need your help to print out everything so we do not include the same restaurants.
- Use a
for
Loop to print out the contents of the array. - Use the
length()
method to find the size of the array. - Look at the example below.
If we are given the array below:
String[] restaurants = { "Burger King", "Chipotle", "Panda Express", "McDonalds" };
the answer should print out:
String answer = "Burger King,Chipotle,Panda Express,McDonalds";
Task 2: Changing Elements
Oh no! McDonalds is out of food! Change the restaurant list before people start ordering from McDonalds, and be disappointed with no food. Luckily “Pizza Hut” is willing to help out! Replace McDonalds with Pizza Hut in the index.
- Launch
- Find the index of McDonalds first
- Remember quotes around
"Pizza Hut"
- Look at the example below!
String[] restaurants = {"Burger King", "Chipotle", "Panda Express", "McDonalds"};
//replace "McDonalds" with "Pizza Hut"