A certain company offers seven annual salary levels (dollars): 12,000, 15,000, 18,000, 24,000, 35,000, 50,000, and 70,000. The number of employees paid at each level are, respectively: 3000, 2500, 1500, 1000, 400, 100, and 25. Write some statements at the command line to find the following: (a) The average salary level. Use mean. (Answer: 32,000) (b) The number of employees above and below this average salary level. Use logical vectors to find which salary levels are above and below the average level. Multiply these logical vectors element by element with the employee vector, and sum the result. (Answer: 525 above, 8000 below) (c) The average salary earned by an individual in the company (i.e., the total annual salary bill divided by the total number of employees). (Answer: 17,038.12)
SOLUTION -
code -
clc
clear all
SL = [12000 15000 18000 24000 35000 50000 70000 ];
NE = [3000 2500 1500 1000 400 100 25 ];
%%(a)
avg_SL = mean(SL);
fprintf('Average salary level =$ %g\n',avg_SL);
%%(b)
% above average salary level
LV = (SL>avg_SL); % logical vector above average salary
level
NE_a = sum(NE.*LV); % no of employees above average salary
level
fprintf('NO of employees above average salary level =
%i\n',NE_a);
% below average salary level
LV = (SL<avg_SL); % logical vector above average salary
level
NE_b = sum(NE.*LV); % no of employees below average salary
level
fprintf('NO of employees below average salary level =
%i\n',NE_b);
%%(c)
AvgSal = sum(SL.*NE)/sum(NE);
fprintf('Average salary earned by an individual =$
%g\n',AvgSal);
SCREENSHOT-
IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I
WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------
Get Answers For Free
Most questions answered within 1 hours.