Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using SWIFT PlayGrounds Functions This homework exercise has three parts: first populate data, next query data and finally update/modify data using different functions. Lets start

Using SWIFT PlayGrounds

Functions

This homework exercise has three parts: first populate data, next query data and finally update/modify data using different functions. Lets start with populating data. This part of the HW is very similar to what you did for HW 1 where car names were populated into an array. Here for HW 2 we will continue to use an Array of strings. First part of the program is to write a function to add car name to your array. For e.g. you may have a function called addCar with will take name that you would like to add to an array. From your main function which is really the place where you are coding in playground. There is no main() function to code, you are in the main function. Here you will call addCar and add 5 car names by doing 5 calls to addCar function. Have another function that checks if specific car name is present in array or not. You may have a function called queryCarName, it will take name of car that you would like to check and the function returns True if car name is present or False if car name is not present in the array. Again, you will call this function from your playground main. Provide a name that you would like to query. If car name is present print Query Successful, car name found! Finally have third function that will modify care name. So, at this point you have an array that has at least 5 car names. You might have function called reverseIt which accepts a string and returns a Boolean value. The function will receive a name that you will query (using function described earlier, queryCarName. If query is successful, modify the array element and reverse the name. For e.g. Kia would be replaced by aiK. This part is a little tricky and you will need to think about reading characters of a string and then reversing it. You will need to use while or for logic in addition to what I have described earlier. Finally print whole array optional exercise to write a function that will print an array. I would expect that if Kia was present, final print would show aiK.

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

Step: 3

blur-text-image

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago