Write a program that has a function that takes a salary as argument. If the salary is less than 20000, give a 20% raise. Return the salary. I was not given any example. I need to know how to start it because I know the formula to raise the salary by 20% is <tot = tot + 0.2 * tot> (or whatever variable I choose to use).
int get_salary(constint salary)
int new_salary = // your calculation here
int orig_salary = 15000;
int new_salary = get_salary(orig_salary);
// show the result
if(sal >= 20000)
//if(sal<=20000) - no need for this test
return(sal + (0.2 * sal));
cout << "Please enter the salary: \n";
cin >> sal;
sal = fun(sal);
cout << "The Final Salary is: " << sal << endl;
// cout << "The Final Salary is: " << (fun(sal)) << endl;
You were calculating the final salary after you printed it.
Your using ints, ints don't have decimal places, you should consider using doubles.