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

(MATLAB PROGRAMMING) Assume the following data shows predictions of increases in

ID: 3845648 • Letter: #

Question

(MATLAB PROGRAMMING)

Assume the following data shows predictions of increases in tuition percentage hikes each year.
Assume the first entry is for year one, and the second entry is for year two an so on.
Ask the user what is their tuition for the first year they would start college, then ask them what year do they expect to start college, then show them their total tuition over 4 years.
E.g., the user may state they will start on year 5 and their starting tuition is $9500.

10, 8, 10, 16, 15, 4, 6, 7, 8, 10, 12, 7, 8, 9, 5, 4, 2

Assume that the user would not start later than year 14 (the data above is for 17 years).
Use a for loop to answer this question.

Explanation / Answer

% lets hike represents the hike in tution fee every year
% startyear and startfee are the year of first year in college and its fee

% totalfee will calculate the fee at the end of four years

% To calculate total fee, we need to add the increased price every year, for the nect 3 years from start year.
% so loop will run for 3 times(not 4)

% if hike is 10, next year fee will be previousYearFee * (10/100 + 1)

% thus, we will loop for 3 times, and calculate the increased fee, and add it to total fee
% and, then update the previousYearFee to hiked fee. Next iteration will add hike on the updated amount

% startyear+a-1 will give the current year, from the first year when the student started the college
% and hike is calculated from that year only

hike = [10 8 10 16 15 4 6 7 8 10 12 7 8 9 5 4 2]

startyear = input('Enter the year in which you will start college')
startfee = input('Enter the tution fee in first year of college ')
totalfee = startfee;

for a = 1:3
totalfee = totalfee + startfee * (hike(startyear+a-1)/100 + 1) % add hike and update totalfee
startfee = startfee * (hike(startyear+a-1)/100 + 1) % update the previousYearFee, so that next year proper fee can be
% calculated using hike percentage
end