Answer to Question #211425 in C++ for jasper

Question #211425

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





1
Expert's answer
2021-06-28T07:24:18-0400
#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;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS