This is the second part that i need help with, part one posted below. First sect
ID: 3670336 • Letter: T
Question
This is the second part that i need help with, part one posted below.
First section:
Also calculate the net profit made by the employer after this downsizing/restructuring: Net profit = total current salaries paid-total new salaries paid Your program should work for any number of employees (changing N, and salary information as applicable). Use iteration for this problem. Test the program for the case: currentsalaries=[30000 50000 100000 60000 30000 40000 25000 50000 70000 65000 40000 25000 90000 80000 30000 40000 70000 50000 60000 45000]; Use MATLAB's fprintf function to clearly display the following in tabular form: Current salaries New salaries Severance Pay in USD 30000 0 50000 51000 100000 105000 and so on 10000 0 Also clearly display the net profit or loss (as applicable) made by the employer.Explanation / Answer
Answer:
function calSalary(currentsalaries)
n=currentsalaries.length;
newsalaries=zeros(1,n);
serverancePay=zeros(1,n);
%CALCUALTING NEWSALARIES AND serverancePay
for k=1:n
if currentsalaries(k)<=30000
newsalaries(k)=0;
serverancePay(k)=10000;
elseif (currentsalaries(k)>30000) && (currentsalaries(k)<=60000)
newsalaries(k)=currentsalaries(k)+currentsalaries(k)*0.02;
serverancePay(k)=0;
elseif (currentsalaries(k)>60000) && (currentsalaries(k)<=80000)
newsalaries(k)=currentsalaries(k)+currentsalaries(k)*0.03;
serverancePay(k)=0;
elseif (currentsalaries(k)>80000 )
newsalaries(k)=currentsalaries(k)+currentsalaries(k)*0.05;
serverancePay(k)=0;
end
%PRINTING INFO
fprintf('Current Salaries New Salaries Severance Pay in USD ');
for k=1:n
fprintf('%d %d %d ',currentsalaries(k),newsalaries(k),serverancePay(k));
end
%TOTAL OF CURRENT SALARIES
currSum=0;
for k=1:n
currSum=currSum+currentsalaries(k);
end
%TOTALOF NEW SALARIES
newSum=0;
for k=1:n
newSum=newSum+newsalaries(k);
end
netprofit=currSum-newSum;
%print NET LOSS/PROFIT
if netprofit < 0
fprintf('NET LOSS : %d',abs(netprofit));
else
fprintf('NET PROFIT : %d',netprofit);
end
end
currentsalaries=[30000 50000 100000 60000 30000 40000 25000 50000 70000 65000 40000 25000 90000 80000 30000 40000 70000 50000 60000 45000];
calSalary(currentsalaries);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.