A local business employs five salespeople and pays a 3% bonus on a salesperson’s sales
Your task is to create a program that calculates the amount of each salesperson’s bonus
The program should print each salesperson’s name and bonus amount
#include <iostream>
#include <iomanip>
using namespace std;
class SalesPerson{
private:
string name;
double salesAmount;
const double percent = 0.03;
public:
SalesPerson(string n, double sA) : name(n), salesAmount(sA) {};
string getName() { return name; };
double getBonusAmount() { return salesAmount * percent; };
};
int main()
{
SalesPerson localBusiness[5] = {
SalesPerson("Alain Delon", 10000),
SalesPerson("John Silver", 15000),
SalesPerson("Uma Thurman", 14000),
SalesPerson("Samantha Smith", 11500),
SalesPerson("Billy Bones", 18000)
};
cout << "This is the bonus of five sellers:" << endl << endl;
for (int i = 0; i < 5; i++) {
cout << "\t" << fixed << setw(15) << localBusiness[i].getName() << "\t";
cout << setprecision(2) << localBusiness[i].getBonusAmount() << endl;
}
}
Comments
Leave a comment