debugging a bonus calculation program

something wrong in the "void calcAndDisplayBonus" function but I don't see it. help?
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
//Ch10AppE10.cpp
//Calculates and displays a bonus amount
//Created/revised by <your name> on <current date>

#include <iostream>
#include <iomanip>

using std::cout;
using std::cin;
using std::endl;
using std::setprecision;
using std::fixed;

//function prototypes
void enterItems(double, double);
void calcAndDisplayBonus(double, double);

int main()
{	
	//declare variables
	double sales     =  0.0;
	double bonusRate =  0.0;

	//enter input values
	enterItems(sales, bonusRate);

	//calculate and display bonus
	cout << fixed << setprecision(2);
	calcAndDisplayBonus(sales, bonusRate);

    return 0;
}   //end of main function

//*****function definitions*****
void enterItems(double salesAmt, double rate)
{
	cout << "Enter sales: ";
	cin >> salesAmt;
	cout << "Enter bonus rate: ";
	cin >> rate;
} //end of enterItems function

void calcAndDisplayBonus(double salesAmt, double rate)
{
	double bonus = salesAmt * rate;

	cout << "Bonus: $" << bonus << endl;
} //end of calcAndDisplayBonus function 
enterItems takes salesAmt and rate by value. So it doesn't pass them back to main.

These parameters should be passed by reference.
Topic archived. No new replies allowed.