Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Function Name: checkInventory % Inputs (2): - (char) a string containing the fil

ID: 3645455 • Letter: F

Question

Function Name: checkInventory
% Inputs (2): - (char) a string containing the filename of the first
% .xls file
% - (char) a string containing the filename of the second
% .xls file
% Outputs (0): None
%
% Function Description:
% You have been hired at an engineering firm, and as the newest member of
% the team, your superior has put you in charge of updating the firm's
% inventory. Your superior has supplied you with a spreadsheet that
% contains part names in the first column and part numbers in the second
% column (the first input excel) and a separate spreadsheet containing
% part numbers in the first column and quantities for each part in the
% second column (the second input excel). Further spreadsheet
% specifications can be found below:
%
% - Spreadsheet One's filename is guaranteed to be in the form
% "<something>_IN_<ID>.xls" (without the quotes) where <something> can
% be any combination of characters and <ID> will always be a
% combination of one capital letter and one number.
% - Spreadsheet Two's filename is guaranteed to be in the form
% "<something>_QU_<ID>.xls" (without the quotes) where <something> and
% <ID> are the same as that of the first spreadsheet.
% - The first row of Spreadsheet One contains the headers "Part Name" and
% "Part Number" (without the quotes) in columns 1 and 2 of the first
% row, respectively.
% - The first row of Spreadsheet Two contains the headers "Part Number"
% and "Quantity" (without the quotes) in columns 1 and 2 of the first
% row, respectively.
% - The part numbers are guaranteed to contain 7 characters, with only
% capital letters and numbers and at least one of each.
% - The values in the "Quantity" column are guaranteed to be filled with
% integers greater than or equal to zero.
% - The spreadsheets are guaranteed to have at least one part name and
% number, and no other data.
% - Part numbers found in either spreadsheet are not guaranteed to appear
% in the other.
%
% Your job is to write a function to combine the spreadsheets in the
% following way:
%
% 1. Check each part in the first spreadsheet to see if its part number
% matches any of the part numbers in the second spreadsheet.
% 2. If a match is found, the part's name, number, and quantity should be
% copied to a new spreadsheet in the first, second, and third columns,
% respectively.
% 3. If no match is found, then the string 'Part Not Found' should appear
% in the quantity column. The part name and number should be copied
% as in step 2.
% 4. The function should then write a spreadsheet called
% "<something>_FINAL_<ID>.xls" (where <something> and <ID> are the
% same as those found in the input spreadsheets and without the
% quotes) with the data found in steps 1-3. The column headers for the
% new spreadsheet should be "Part Name", "Part Number", and
% "Quantity", in that order (without the quotes).
%
% Hints:
% - Check out what strcmp() does if one or both of the inputs is a cell
% array of the same length.
% - You should only be using xlswrite() once. Remember that you can
% hold all of your information in a cell array and then use
% xlswrite() on that cell array to write the spreadsheet.
% - The strfind() function may be helpful in determining what
% <something> and <ID> are.
%
% Test Case:
% ss1 = 'inventory_IN_A1.xls';
% ss2 = 'inventory_QU_A1.xls';
% checkInventory(ss1, ss2);
% => spreadsheet should be named "inventory_FINAL_A1.xls" and should
% look like "inventory_FINAL_A1_SOLUTION.xls"
%

Explanation / Answer

MATLAB (matrix laboratory) is a numerical computing environment and fourth-generation programming language. Developed by MathWorks, MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++, Java, and Fortran. Although MATLAB is intended primarily for numerical computing, an optional toolbox uses the MuPAD symbolic engine, allowing access to symbolic computing capabilities. An additional package, Simulink, adds graphical multi-domain simulation and Model-Based Design for dynamic and embedded systems. In 2004, MATLAB had around one million users across industry and academia.[2] MATLAB users come from various backgrounds of engineering, science, and economics. MATLAB is widely used in academic and research institutions as well as industrial enterprises.