A certain company offers seven annual salary levels: $12,000. $15,000. $18,000.
ID: 1839755 • Letter: A
Question
A certain company offers seven annual salary levels: $12,000. $15,000. $18,000. $24,000. $35,000. $50,000, and $70,000. The number of employees paid at each level is. respectively: 3000.2500.1500,1000.400.100, and 25. Write some statements at the command line to find the following: The average salary level. Use mean. The number of employees above and below tills level. Use logical vectors to find which levels are above and below the average Multiply them element by element with the employee vector, and sum the result. The average salary earned (i.a, the total annual salary divided by the total number of employees). (Answer: $17,038.12).Explanation / Answer
sal= [12 15 18 24 35 50 70];
sal=sal.*1e3;%sal is salary level vector
emp = [3000 2500 1500 1000 400 100 25];
avg=mean(sal);
m=0;%m for number of employees above average salary
n=0;%n for number of employees below average salary
for k=1:7
if sal(k)>=avg
m=m+emp(k);
else
n=n+emp(k);
end
end
d=zeros(1,7);
for k=1:7
d(k)=sal(k).*emp(k);
end
avg_sal=sum(d)./sum(emp);
disp(['average salary level = $' num2str(avg)]);
disp(['number of employees above average salary level = ' num2str(m)]);
disp(['number of employees below average salary level = ' num2str(n)]);
disp(['average salary = $' num2str(avg_sal)]);
>> m6
average salary level = $32000
number of employees above average salary level = 525
number of employees below average salary level = 8000
average salary = $17038.1232
>>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.