Please the code most be by matlab. Project You have been contracted to write a p
ID: 667949 • Letter: P
Question
Please the code most be by matlab.
Project You have been contracted to write a program that will analyze the cost and efficiency of driving a car. Create an M - file that defines three variables; gallons Of Gas, miles Driven, and costPerGallon. Each of these should have a value assigned to them in the program. The program will then calculate the gas mileage, the total cost, and the cost per mile. It should print a nicely formatted output showing all three inputs and the three outputs. In addition every program that you submit must include introductory comments consisting of your name, the date, and a description of the program.Explanation / Answer
function [cost] = roadTrip(carDistance, gasGallons, totalMiles, gasPrice) % Total cost is determined by dividing the total distance by % distance traveled on one tank multiplyed by tank size and price per % gallon cost = (totalMiles./carDistance).*gasGallons.*gasPrice; % In order to round we must multiply by 100, round, and then divide. cost = cost .* 100; cost = ceil(cost); cost = cost ./ 100;