diff options
Diffstat (limited to '7b/9.4Exercise/9.4Exercise.cpp')
| -rw-r--r-- | 7b/9.4Exercise/9.4Exercise.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/7b/9.4Exercise/9.4Exercise.cpp b/7b/9.4Exercise/9.4Exercise.cpp new file mode 100644 index 0000000..3e76174 --- /dev/null +++ b/7b/9.4Exercise/9.4Exercise.cpp @@ -0,0 +1,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 << "."; +}
\ No newline at end of file |