Answer to Question #167162 in C++ for blessing

Question #167162




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

Monthly Salary (R) 0 0 0 0 0 0 0 0



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






1
Expert's answer
2021-02-26T12:08:47-0500
#include <iostream>

int main()
{
    const int Employee_Count = 8;
    int annualSalary[Employee_Count] = { 150000, 250000, 650000, 99000, 68000, 35000, 95000, 28000 };
    int monSalary   [Employee_Count] = { 0, 0, 0, 0, 0, 0, 0, 0 };

    std::cout << "Initial annual salary:\n";
    for(int i=0; i<Employee_Count; ++i)
    {
        std::cout << "R" << annualSalary[i] << "\n";
    }

    int increaseCount = 0;
    for(int i=0; i<Employee_Count; ++i)
    {
        if(annualSalary[i] < 100000)
        {
            annualSalary[i] += 10000;
            ++increaseCount;
        }
    }    

    std::cout << "\nNumber of employees whose salary has been increased: " << increaseCount << "\n";

    std::cout << "\nNew annual salary and the monthly salary:\n";

    int averageSalary = 0;
    int highestAnnualSalary = annualSalary[0];
    
    for(int i=0; i<Employee_Count; ++i)
    {
        monSalary[i] = annualSalary[i] / 12;

        std::cout << "R" << annualSalary[i] << "\tR" << monSalary[i] << "\n";

        averageSalary += annualSalary[i];

        if(highestAnnualSalary < annualSalary[i])
        {
            highestAnnualSalary = annualSalary[i];
        }
    }

    averageSalary /= Employee_Count;
    
    std::cout << "\nAverage salary:        R" << averageSalary << "\n";
    std::cout << "Highest annual salary: R" << highestAnnualSalary << "\n";
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog