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
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