Describe what the following program does, and explain role of each line of code:
ID: 3659129 • Letter: D
Question
Describe what the following program does, and explain role of each line of code:
BigShot(10000)
BigShot(40000)
BigShot(80000)
BigShot(120000)
for k=1:15
salary(k)=k*10000;
savings(k)=BigShot(salary(k));
end
plot(salary,savings)
A Math-lab separate file!
function output = BigShot(salary)
if salary<=30000
my_share=salary*0.1;
company_share = salary*0.1;
output = my_share + company_share;
elseif salary<=60000?my_share=salary*0.1;?company_share = 30000*0.1 + (salary-30000)*0.05; output = my_share + company_share;
elseif salary<=100000?my_share = 60000*0.1 + (salary-60000)*0.08; company_share = 0.1*30000 + 0.05*30000; output = my_share + company_share;
else
my_share = 60000*0.1 + 40000*0.08;
company_share = 0;
output = my_share + company_share;
end
Explanation / Answer
Whenever the value of k varies from 1 to 4 to 8 to 12,bigshot(k) is saved to savings(k). And whereas in matlab file,when salary is greater than 30000,myshare and companyshare are calculated and summed to total share and else different output share is calculated.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.