Answer to Question #291897 in MatLAB for Mr Z

Question #291897

You are given the price list of certain equipment (Table 1).

Write a script or function that takes an input for the number of items from each equipment and calculates the total number of equipment, total cost, and average cost per item.


(Table 1: Price List: )

Equipment Price (£)

Power generator 30

Transformer 10

Stepper motor 15

DC motor 8.5




1
Expert's answer
2022-01-29T09:05:16-0500
equipment = ["Power generator", "Transformer", "Stepper motor", "DC motor"];
price = [30, 10, 15, 8.5];
n = 4;
tot_number = 0;
tot_cost = 0;
for i=1:n
    number = input("Enter number of " + equipment(i) + ": ");
    tot_number = tot_number + number;
    tot_cost = tot_cost + number * price(i);
end
avg_cost = tot_cost /tot_number;
fprintf("\n");
fprintf("The total number of equipment: %d\n", tot_number);
fprintf("The total cost: £%.2f\n", tot_cost);
fprintf("The average cost £%.2f per item\n", avg_cost);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS