aboutsummaryrefslogtreecommitdiff
path: root/7b/9.4Exercise/9.4Exercise.cpp
blob: 3e7617425e4dd82ded407072d82209e29ceb4d2c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 9.4Exercise.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

void GetInput(float& salary, int& years_service);
void CalcRaise(float& salary, int years_service);
int CalcBonus(int years_service);
void PrintCalculations(int years_service, float salary, int bonus);

int main()
{
    float salary;
    int bonus, years_service;

    GetInput(salary, years_service);
    CalcRaise(salary, years_service);
    bonus = CalcBonus(years_service);
    PrintCalculations(years_service, salary, bonus);
}


void GetInput(float& salary, int& years_service)
{
    cout << "Input the employee salary: ";
    cin >> salary;

    cout << "\nInput the years the employee has worked: ";
    cin >> years_service;
    cout << "\n\n";
}

void CalcRaise(float& salary, int years_service)
{
    if (years_service >= 10)
    {
        salary *= 1.1;
    }
    else if (years_service >= 5)
    {
        salary *= 1.05;
    }
    else
    {
        salary *= 1.02;
    }
}

int CalcBonus(int years_service)
{
    int bonus;
    bonus = (years_service / 2) * 500;
    return bonus;
}

void PrintCalculations(int years_service, float salary, int bonus)
{
    cout << "The employee has worked for " << years_service << " and as a result their new salary will be: $" << salary << ", and they will recive a bonus of: $" << bonus << ".";
}