College ABC has recruited new employees that they pay a certain annual salary as given below. Table 1.1 Annual Salary in Rands R150 000 R250 000 R650 000 R99 000 R68 000 R35 000 R95 000 R28 000 Write a C++ program called Salaries.cpp for the college’s salary administration, the program must do the following: Declare an array called annualSalary and populate it using the values given above. Declare an array called monSalary and populate it using default values. Display all the contents in the annual salary array. Increment the annual salary for all the employees who earn less than R100 000 by adding R10 000 for each employee in this category, and then count how many employees who got an increase. Calculate the monthly salary and display both the new annual salary as well as the monthly salary. Calculate and display the average salary. Find and display the highest annual salary.
#include <bits/stdc++.h>
using namespace std;
#define NO_OF_EMP 8
main(void)
{
float annualSalary[NO_OF_EMP],MonSalary[NO_OF_EMP],Avg=0,Max;
int n,Inr=0,Ind=0;
annualSalary[0] = 150000;
annualSalary[1] = 250000;
annualSalary[2] = 650000;
annualSalary[3] = 99000;
annualSalary[4] = 68000;
annualSalary[5] = 35000;
annualSalary[6] = 95000;
annualSalary[7] = 28000;
Max = annualSalary[0];
cout<<"\nEmp. ID\tAnnual Salary\tMonthly Salary\n";
for(n=0;n<NO_OF_EMP;n++)
{
MonSalary[n] = annualSalary[n]/12;
Avg = Avg + annualSalary[n];
if(Max<=annualSalary[n]) {Max = annualSalary[n]; Ind=n;}
cout<<setprecision(7)<<n+1<<"\t"<<annualSalary[n]<<"\t\t"<<int(MonSalary[n])<<endl;
}
Avg = Avg/NO_OF_EMP;
cout<<"\nMax. Salary = "<<Max<<"\tEmp. ID = "<<Ind;
cout<<"\nAverage Annual Salary before increment: "<<Avg;
Avg=0;
cout<<"\n\nSalaries after Increment\n";
cout<<"\nEmp. ID\tAnnual Salary\tMonthly Salary\n";
Max = annualSalary[0];
Inr=0;
Ind=0;
for(n=0;n<NO_OF_EMP;n++)
{
if(annualSalary[n]<100000) {annualSalary[n] = annualSalary[n]+10000;Inr++;}
Avg = Avg + annualSalary[n];
if(Max<=annualSalary[n]) {Max = annualSalary[n]; Ind=n;}
MonSalary[n]=annualSalary[n]/12;
cout<<setprecision(7)<<n+1<<"\t"<<annualSalary[n]<<"\t\t"<<int(MonSalary[n])<<endl;
}
Avg = Avg/NO_OF_EMP;
cout<<"\nNo. of Emp. who got increment = "<<Inr;
cout<<"\nMax. Salary = "<<Max<<"\tEmp. ID = "<<Ind;
cout<<"\nAverage Annual Salary after increment: "<<Avg;
return(0);
}
Comments
Leave a comment