Use vector operations like element-by-element multiplication and the sum command
ID: 2253168 • Letter: U
Question
Use vector operations like element-by-element multiplication and the sum command so that your program would work with any number of bedroom set types. A discount furniture store sells four types of bedroom sets. The cost (in dollars) of each set can be represented by the array Cs = [ 199, 2 68 , 500, 670] . The price at which the store sells each set can be represented by the array Ps = [ 398 , 598, 798, 998]·in a particular quarter the number of sets sold of each type can be represented by the array Ns = [ 35, 25, 20 , 10], write a program, furniture.m, that calculates and reports: a. b. c. The total number of bedroom sets sold. The total revenue received by the store from the number of sets sold. The profit realized by the store from the sale of bedroom sets.Explanation / Answer
edit furniture.m
Cs=[199 268 500 670];
Ps=[398 598 798 998];
Ns=[35 25 20 10];
a).num=sum(Ns); % sum of elements in Ns =90
b).rev=Ns.*Ps; %element by element multiplication to find total revenue
c).profit=Ns.*Ps-Ns.*Cs
disp()
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.