Hello again,
My assignment is to calculate a 10% bonus based on sales figures. I have to use a main() function, obviously, and 3 void functions, getSales(), calcBonus(), and displayBonus().
I'm pretty sure I have the functions coded correctly, I'm just having some issues getting them to actually run correctly within the structure of my main() function.
Here's the code so far.
//Ch10AppE03.cpp
//Calculates and displays a bonus amount
//Created/revised by Greg Schader on 7/6/2009
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::setprecision;
using std::fixed;
//function prototypes
void getSales();
void calcBonus(double, double);
void displayBonus(double);
int main()
{
//declare constant and variables
const double RATE = .1;
double sales = 0.0;
double bonus = 0.0;
//get input item
getSales();
//calculate bonus
//display output item
cout << fixed << setprecision(2);
return 0;
} //end of main function
//*****function definitions*****
void getSales()
{
double sales = 0.0;
while (sales != 0)
{
double salesTotal = 0.0;
cout << "Enter the sales amount (0 to stop): ";
cin >> salesTotal;
sales = sales + salesTotal;
}
}
void calcBonus(const double RATE, double sales)
{
double bonus = 0.0;
bonus = sales * RATE;
}
void displayBonus(double bonus)
{
cout << "Bonus is: $" << bonus << endl;
}