Question: Write a MacOS Playground file in Swift to: 1 . Create a dictionary of products, in which each key is a product name (e.g., Strawberry

Write a MacOS Playground file in Swift to:

1. Create a dictionary of products, in which each key is a product name (e.g., Strawberry Ice Cream) and its value is a tuple including the category and price of the product (e.g., (Dissert, 3.99))

2. Declare three functions:

lowestPrice function returns name and price of the product that has the lowest price among all given products.

highestPrice function returns name and price of the product that has the highest price among all given products.

price function takes two arguments:

a) a dictionary of products

b) a reference to a function

Function price should return the name and price of the product that has the lowest price, if a reference to function lowestPrice is passed as argument b).

Similarly, function price should return the name and price of the product that has the highest price, if a reference to function highestPrice is passed as argument b),

3. Include some necessary statements to test your work for steps 1 and 2

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 Databases Questions!