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
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
Comments
Leave a comment