Answer to Question #291895 in MatLAB for Mr Z

Question #291895

Write a script of function that will take an input as the total budget and calculate how many items can be purchased for each equipment


1
Expert's answer
2022-01-29T09:05:18-0500
equipment = ["Power generator", "Transformer", "Stepper motor", "DC motor"];
price = [30, 10, 15, 8.5];
n = 4;

budget = input("Enter the total budget: ");
fprintf("\n");

for i=1:n
    number = floor(budget / price(i));
    fprintf("For £%.2f you may purche %d %s(s)\n", ...
            budget, number, equipment(i));
end

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