Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have been hired by a used-car dealership to modify the price of cars that ar

ID: 3631037 • Letter: Y

Question

You have been hired by a used-car dealership to modify the price of cars that are up for sale. You get information about a car and then change its price tag depending on a number of factor s.
o Write a function makeusedcar.m that creates the structure car with the following fields:
? Make: a string that represents the make of the car (e.g.: ‘Toyota Corolla’, ‘Honda Civic’, etc. )
? Year: a number that corresponds to the year of the car (e.g.: 1997, 2006, etc.) ? Cost: a number that holds the marked price of the car in USD (e.g.: 7000, 10000, etc.)
? Miles: the number of miles clocked (e.g.: 85000, 20000, etc.)
? Accidents: the number of accidents the
car has been in (e.g.: 1, 2, etc.)
o Write a program mycardealership.m that uses the function makeusedcar.m to create a structure array cars with the
following information for N=3 cars:
? 'Honda Civic', 1999, $6988, 132733 miles, 0 (none) accidents
? 'Toyota Corolla', 2006, $15999, 21380 miles, 2 accidents
? 'Ford F150', 2005, $14999, 18580 miles, 1 accident

o Write a function usedcarprice.m that takes in a structure such as car as its input and returns its final price as output based on the following factors:

? Add $5000 to the cost if the car has clocked less than 20,000 miles.
? Subtract $5000 from the cost if it has clocked more than 100,000 miles.
? Reduce the price by $10,000 for every accident.
? Add $6000 to the cost if the car is less than or equal to 3 years old.
? Subtract $6000 to the cost if it is more than 10 years old.
? If the final price of a car computes to be $0 or less, set the final price to be exactly $0.
o Include in the program mycardealership.m commands to calculate the final price of each of the N cars using the function usedcarprice.m.
o Include in the program mycardealership.m commands to find the most expensive car in the dealership. Your program should display the make, year, and other information for this car.
o Include in the program mycardealership.m commands to calculate the total cost of all N cars in the dealership. Your program should display this total cost.
o Your program and functions should work for any number of cars with any inputs (any N, any model, year, etc.).

Explanation / Answer

function makeusedcar(a)

car = struct('Make', {}, 'Year', [],'Cost',[],'Miles',[],'Accidents',[])

end

function mycardealership()

makeusedcar('Toyota')

car = struct('Make',{{'TOyota' 'Honda' 'civic fiate'}},'Year',[1999 1996 2009],'Cost',[7000 10000 9000],'Miles',[85000 20000 18500],'Accidents',[0 2 1])

for i=1:3

car.Make

car.Year

car.Cost

car.Miles

car.Accidents

end

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote