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 <iostream>
using namespace std;
int main()
{
double annualSalary[] = { 50000, 70000, 80000, 120000, 140000, 25000, 185000, 85000, 32000, 215000 };
double monSalary[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
for (int i = 0; i < 10; i++)
{
cout << "Annual Salary of " << i << " employee is: " << annualSalary[i] << endl;
}
int countIncrease = 0;
for (int i = 0; i < 10; i++)
{
if (annualSalary[i] < 100000)
{
countIncrease++;
annualSalary[i] += 10000;
}
}
cout << endl << countIncrease << " got an increase a annual salary." << endl << endl;
for (int i = 0; i < 10; i++)
{
monSalary[i] = annualSalary[i] / 12;
cout << "Annual Salary is: " << annualSalary[i] << " and the Month Salary is: " << monSalary[i] << " of " << i << " emplyee." << endl;
}
cout << endl;
double sum = 0;
for (int i = 0; i < 10; i++)
{
sum += monSalary[i];
}
double averageSalary = sum/10;
cout << "Average salary is: " << averageSalary << endl << endl;
double max = annualSalary[0];
for (int i = 1; i < 10; i++)
{
if (annualSalary[i] > max) max = annualSalary[i];
}
cout << "Max annual salary is: " << max << endl;
return 0;
}
Comments
Leave a comment