From 082b47a6b127249ea86310965090204b25f27944 Mon Sep 17 00:00:00 2001 From: LTB-Pravda <91996618+LTB-Pravda@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:04:12 -0700 Subject: Additions (9.3 and 9.3) are at the bottom of the program --- CST116F2021-Lab4/CST116F2021-Lab4.cpp | 71 ++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/CST116F2021-Lab4/CST116F2021-Lab4.cpp b/CST116F2021-Lab4/CST116F2021-Lab4.cpp index 50c8e11..0720328 100644 --- a/CST116F2021-Lab4/CST116F2021-Lab4.cpp +++ b/CST116F2021-Lab4/CST116F2021-Lab4.cpp @@ -404,4 +404,73 @@ int main() cout << endl; } return 0; -}*/ \ No newline at end of file +}*/ +/* +#include +using namespace std; +int main() +{ + int var_a = 1, + var_b = 2, + var_c = 3; + //return (void); - no error + //int return; - syntacial error as it's tryingto make return a variable, but it cannot. + //return var_a; - no error + //return (var_a, var_b, var_c); - runtime error. Only returns var_c + //return (var_a + var_b); - no error + //return; - no error + //return (true); - no error + //return('A', 'B'); - runtime error. Only shows ascii value of 'B' +}*/ +#include +#include +using namespace std; +void GetInputs(float&, int&); +void CalcRaise(float&, int&); +int CalcBonus(int); +void PrintCalculations(int, float, int); +int main() +{ + float salary; + int years; + int bonus; + + GetInputs(salary, years); + CalcRaise(salary, years); + bonus = CalcBonus(years); + PrintCalculations(years, salary, bonus); + + return 0; +} +void GetInputs(float& salary, int& years) +{ + cout << "What is the employee's Salary? "; + cin >> salary; + cout << endl; + cout << "How many years has the employee worked? "; + cin >> years; + cout << endl; + return; +} +void CalcRaise(float& salary, int& years) +{ + if (years > 10) + salary += salary * .1; + else if (years >= 5) + salary += salary * .05; + else + salary += salary * .02; + return; +} +int CalcBonus(int years) +{ + int bonus; + bonus = (years / 2) * 500; + return bonus; +} +void PrintCalculations(int years, float salary, int bonus) +{ + cout << "Becuase the employee has worked " << years << " years:\n" + << "Their new salary is $" << salary << endl + << "They recieve a bonus of $" << bonus << endl; +} \ No newline at end of file -- cgit v1.2.3