Question
USE MATLAB TO SOLVE, NO HARD CODING Function Name: pillagePublix Inputs: 1. (cell) An MX3 cell array containing the Publix inventory 2. (char) A string
USE MATLAB TO SOLVE, NO HARD CODING
Function Name: pillagePublix
Inputs: 1. (cell) An MX3 cell array containing the Publix inventory 2. (char) A string containing your grocery list
Outputs: 1. (cell) An MX3 cell array containing the updated Publix inventory 2. (char) A string describing the total cost of your groceries
Topics: (cell array manipulation), (iteration)
Background: Shiver me timbers! You grew up hearing horror stories about pirate diets, but when you pledged your life to piracy, you didn't expect it to actually be this bad. It's almost pi day, and you're craving something that isn't rotten, stale, or covered in salt. You've finally convinced your fellow crewmates to stop by the grocery store for all the necessary ingredients - keeping things professional, of course. Time to pillage Publix.
Function Description: You are given a cell array containing the Publix inventory, where the first column holds the item name (type char), the second column contains the quantity of that item that Publix has in stock (type double), and the third column is the unit price of that item in dollars (type double). You are also given a string containing what you need to buy, formatted '
Example: inventory = {'Apple', 18, 0.52; 'Salt', 50, 1.37; 'Flour', 29, 3.20} list = 'flour-3,APPLE-15' [updatedInventory, sent] = pillagePublix(inventory, list) updatedInventory -> {Apple, 3, 0.52; Homework 08 - Cell Arrays Salt, 50, 1.37; Flour, 26, 3.20} sent -> 'My total is $17.40.'
Notes: You can have more than one item on your list Every item on your list will exist in the inventory. There will always be enough of each item to buy what you need. Case does not matter.
Hints: Think about how you can format a number with two decimal points in a string. Recall which string functions work on cell arrays!
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