Array of Create a function called CreateArrayOfStructure to create an array of structs called pizzasinStore with 3 field

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Array of Create a function called CreateArrayOfStructure to create an array of structs called pizzasinStore with 3 field

Post by answerhappygod »

Array Of Create A Function Called Createarrayofstructure To Create An Array Of Structs Called Pizzasinstore With 3 Field 1
Array Of Create A Function Called Createarrayofstructure To Create An Array Of Structs Called Pizzasinstore With 3 Field 1 (36.66 KiB) Viewed 43 times
Array Of Create A Function Called Createarrayofstructure To Create An Array Of Structs Called Pizzasinstore With 3 Field 2
Array Of Create A Function Called Createarrayofstructure To Create An Array Of Structs Called Pizzasinstore With 3 Field 2 (38.14 KiB) Viewed 43 times
Array Of Create A Function Called Createarrayofstructure To Create An Array Of Structs Called Pizzasinstore With 3 Field 3
Array Of Create A Function Called Createarrayofstructure To Create An Array Of Structs Called Pizzasinstore With 3 Field 3 (27.68 KiB) Viewed 43 times
Array of Create a function called CreateArrayOfStructure to create an array of structs called pizzasinStore with 3 fields: name, a string scalar with the name of the pizza, ingredients, a string scalar with the ingredients, and calories, a numeric variable with the total calories. The first item in pizzasinStore is associated with the "Barbecue" pizza, then "Carbonara" pizza, and finally "Ham and Cheese" pizza. In a "Barbecue" pizza, the ingredients are "Beef, chicken, bacon, barbecue sauce" and the calories equal an integer, which is an input parameter of the function CreateArrayOfStructure called numCalofBBQ. In a "Carbonara" pizza, the ingredients are "Mushrooms, onion, creamy sauce" and the calories equal 5 calories less that the "Barbecue" pizza. In a "Ham and Cheese" pizza, the ingredients are "Ham, cheese, bacon" and the calories equal the "Barbecue" pizza. Ex: >> numberCalofBBQ = 30; pizzasInStore= CreateArrayOfStructure (numberCalofBBQ) pizzasInStore = 1x3 struct array with fields: name ingredients calories >>pizzasInStore.name ans = "Barbecue" ans = structures "Carbonara" ans = "Ham and Cheese" >> pizzasInStore. ingredients ans = "Beef, chicken, bacon, barbecue sauce" "Mushrooms, onion, creamy sauce" "Ham, cheese, bacon" >> pizzasInStore.calories ans = ans = ans =
ans = "Ham, cheese, bacon" >> pizzasInStore.calories ans = ans = ans = 30 3 Function 4 25 5 1 function pizzasInStore= CreateArrayOfStructure (numberCalofBBQ) 2 **** Barbecue pizza, the ingredients are Beef, chicken, bacon, barbecue sauce .. and the calories equals an integer variable. Carbonara pizza, the ingredients are Mushrooms, onion, creamy sauce... and the calories equals 5 calories less that the Barbecue pizza. 30 6 N Save C Reset P % Ham and Cheese pizza, the ingredients are Ham, cheese, bacon... N and the calories equals that of the Barbecue pizza pizzasInStore=struct 9 pizza_name=('Barbecue', 'Carbonara', 'Ham and Cheese'); 10 pizza ingredients=('Beef, chicken, bacon, barbecue sauce', 'Mushrooms, onion, creamy sauce', 'Ham, cheese, b 11 pizza_calories= [numberCalofBBQ, numberCalofBBQ-5, numberCalofBBQ]; 12 13 for i=1: numel(pizza_calories) 14 15 16 17 end 18 end 19 MATLAB Documentation. pizzasInStore (1).name=string(pizza_name(i)); pizzasInStore (1).ingredients string(pizza_ingredients(i)); pizzasInStore(i). calories-pizza_calories (i);
Assessment: 3 of 4 Tests Passed (75%) Check the array of struct is correctly initialized. Variable output has an incorrect value. The struct is not initialized correctly. Check a string datatype is used for the field name. Check a string datatype is used for the field ingredients. Check a numeric datatype is used for the field calories. How was this section? Provide feedback Submit 0% (25%) (25%) 25% (25%) 25% (25%) Total: 75% Feedback?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply