Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Requirements: Open a new Xcode Playground (click Get started with a playground and choose Blank playground) and name it LastName07. playground (use your own Last
Requirements: Open a new Xcode Playground (click Get started with a playground and choose Blank playground) and name it LastName07. playground (use your own Last Name). Do not alter the import statement at the top that imports UIKit (it should remain). Remove the "Hello, playground" variable declaration. Add a comment at the top of the playground with your first and last name. Example: //Jamie Pinchot Note that in the following steps, when you see a blank like this: , you should fill it with the appropriate value from the step (e.g. constant or variable). Add a comment for each of the steps below; the comment should appear just above your response for that step number. Just below the comment, add a print statement that will print out the step number, as well as two new line characters, one before and one after the step number. For example, for the first step, add the following: // Step H1 print ( "InStep \#1 ) 1. Create a variable called schoolSupplies that is an array of Strings. Initialize the array to include at least 5 elements of your choice (for example: "pencil", "pen", "notebook", etc.). Use the sort function to sort the array in alphabetical order. Then, use a for-in loop to loop through the sorted array and print out every element. The output should appear in alphabetical order, regardless of the order in which you add the elements to the array. 2. Create a variable called bookTitles that is an array of Strings. Initialize the array, as follows, to include these five book titles (or other titles of your choice): var bookTitles = ["The Great Gatsby", "The Lord of the Rings", "Alice's Adventures in Wonderland", "The Old Man and the Sea", "Jane Eyre"] 2. Create a variable called bookTitles that is an array of Strings. Initialize the array, as follows, to include these five book titles (or other titles of your choice): var bookTitles = ["The Great Gatsby", "The Lord of the Rings", "Alice's Adventures in Wonderland", "The Oid Man and the Sea", "Jane Eyre"] Use a for-in loop to loop through all of the elements in the array, from 1 to the count of array elements. Inside the loop, create a constant called randomNumber and set it equal to a random integer that could be any number up to the count of the bookTitles array elements. Hint: use the arc4random function - details found in Blackboard. Then, print out the loop index followed by a period, then a space, and then a book title from the bookTitles array at the index of randomNumber. As a result, your loop should print out a numbered list ( 1 to 5) and for each item, it should print a random book titie (some may repeat). The items will change every time you run the code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started