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

Array of Structures Create a function CreateArrayOfStructure to create an array

ID: 2249591 • Letter: A

Question

Array of Structures Create a function CreateArrayOfStructure to create an array of structs pizzaslnStore with 3 fields: one field is name that is a string with the name of the pizza, next is ingredients that is a string with the ingedients, and the third calories that is a numeric with the total calories. The first item in pizzasln Store is associated with the "Barbecue" pizza, then "Carbonara" and finally "Ham and Cheese". In a "Barbecue" pizza, the ingredients are "Beef, chicken, bacon, barbecue sauce" and the calories equals an integer, which is an input parameter of the function CreateArrayOfStructure. In a "Carbonara" pizza, the ingredients are "Mushrooms, onion, creamy sauce" and the calories equals 5 calories less that the "Barbecue" pizza. In a "Ham and Cheese" pizza, the ingredients are "Ham, cheese, bacon" and the calories equals the "Barbecue" pizza. Your Function Save Reset MATLAB Documentation I function pizzas!nstore = createArray0fstructure(numbercalofBBQ) 2 % Barbecue pizza, the ingredients are Beef, chicken, bacon, barbecue sauce 3 % and the calories equals an integer variable 4 % Carbonara pizza, the ingredients are Mushrooms, onion, creamy sauce 5 % and the calories equals 5 calories less that the Barbecue pizza. 6 % Ham and Cheese pizza, the ingredients are Ham, cheese, bacon 7%and the calories equals that of the Barbecue pizza 8 9% Your code goes here % 10 end 12 13 Code to call your function C Reset 1numberCalofBBQ 30; 21 pizzas!nstore = CreateArrayofstructure (numberCalofBBQ) Run Function

Explanation / Answer

Matlab Script:

function pizzasInStore = CreateArrayOfStructure(numberCalofBBQ)
pizzasInStore(1).name = 'Barbecue';
pizzasInStore(1).ingredients = 'Beef, chicken,backon barbecue sauce';
pizzasInStore(1).calories = numberCalofBBQ;%for Barbecue number calories equal to input to the function
pizzasInStore(2).name = 'Carbonara';
pizzasInStore(2).ingredients = 'Mushrooms, onion, creamy sauce';
pizzasInStore(2).calories = numberCalofBBQ-5;%for Carbonara number calories are 5 less than Barbecue
pizzasInStore(3).name = 'Ham and Cheese';
pizzasInStore(3).ingredients = 'Ham, cheese, bacon';
pizzasInStore(3).calories = numberCalofBBQ;%number of calories equal to Barbecue
end

command window output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote