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

THIS IS MATLAB CODE NOT JAVA PYTHON OR C++ plEASE HELP 1. The cost per mile for

ID: 3819845 • Letter: T

Question

THIS IS MATLAB CODE NOT JAVA PYTHON OR C++ plEASE HELP

1. The cost per mile for a rented vehicle is $ 1.00 for the first 50 miles, $0.75 for the next 200 miles, and $0.50 for all miles in excess of 250 miles. Write a MATLAB program (rentalcar,m) to determine the total cost for a user given number of miles.

2. Write a program that accepts a month and a year (both in numbers) from the user and prints out the number of days in that month. Background: There are 31 days in January, March, May, July, August, October, or December, and 30 days in April, June, September, or November. If the year is a leap year, February has 29 days, otherwise it has 28 days. Any year that is evenly divisible by 4 is a leap year. For example, 1988, 1992, and 1996 are leap years. However, there is still a small error that must be accounted for. To eliminate this error, a year that is evenly divisible by 100 (for example, 1900) is a leap year only if it is also evenly divisible by 400. For this reason, the following years are not leap years: 1700, 1800, 1900, 2100, 2200, 2300, 2500, 2600. This is because they are evenly divisible by 100 but not by 400. The following years are leap years: 1600, 2000, 2400. To determine if a number x is evenly divisible by another number y, in MATLAB, you can call a build-in function mod(x,y). If mod(x,y) is equal to 0, x is evenly divisible by y. For example, mod(1900, 100) is 0 and mod(1900,400) is 300

Explanation / Answer

Answers

1) rentalcar.m

prompt = 'Enter Miles'

x= input(prompt)

if (x<=50)

charge=1.00*x

elseif ( x>50 && x<=250)

charge=50*1.00 + (x-50)*0.75

elseif ( x>250
)
charge=50*1.00 + (x-50)*0.75 + (x-250)*0.50

end

2) dayscount.m

prompt1='Enter Month'
month=input(prompt1)
prompt='Enter Year'
year=input(prompt)
if (mod(year,4) == 0)
if(month==2)
days=29
end

elseif (month==2)
days=28

end

if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
days=31
elseif (month==4 || month==6 || month==9 || month==11)
days=30

end