pass-by-reference help
Nov 22, 2014 at 1:17am UTC
I have written the following to code calculate and display raises of 5% and 10%. My output is not calculating the 10% raise correctly. Any idea what I am coding wrong?
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
void fivePercentRaise(double &);
double tenPercentRaise(double );
int main()
{
double salary = 0.0;
cout <<"Please enter current salary: " ;
cin >>salary;
fivePercentRaise(salary);
tenPercentRaise(salary);
system("pause" );
return 0;
}
void fivePercentRaise(double & sal)
{
sal= sal + sal * 0.05;
cout <<"New salary if you receive a 5% raise: " << sal << endl;
}
double tenPercentRaise(double sal)
{
double newSal = sal + sal * 0.10;
cout <<"New salary if you receive a 10% raise: " << sal << endl;
}
Nov 22, 2014 at 1:19am UTC
Topic archived. No new replies allowed.