It is my matlab question. I need exactly answer cords. I got the cord already in
ID: 3576092 • Letter: I
Question
It is my matlab question. I need exactly answer cords. I got the cord already in chegg. But, I think it is wrong. I need correct answer. Car salespeople advertise car costs using the selling price, along with the MPG. Honest car salespeople publish the more detailed MPG: MPG1 is for highway and MPG2 for in-town. Write a function named average cost that takes an array of the base price of a car, MPG1, MPG2 and the average miles driven annually. Assume a gas price of $3.00 per gallon, calculate the total cost of ownership of a car. Return that value.Explanation / Answer
% average_cost.m file
function cost = average_cost(arr)
GasCost1 = (arr(4)/arr(2))*3;
GasCost2 = (arr(4)/arr(3))*3;
TC1 = arr(1) + GasCost1;
TC2 = arr(1) + GasCost2;
cost = (TC1+TC2)/2;
% demo.m file
arr = [50;20;10;1000];
cost = average_cost(arr);
fprintf('Average cost : %f ',cost);
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.