Start learning free

LESSON 53 OF 667 · CALCULATIONS - CHALLENGES

Employee of the Year V1 - Project

Practice

Compute an end-of-year performance bonus for one employee, then print the employee's name and the bonus.

You start with:

string name = "John Doe";
int productivity = 83;
int salary = 135000;

Build:

John Doe
Bonus: $20250

Rules:

  • The bonus is 15% of the salary, rounded down to a whole number.
  • Print the employee's name on the first line.
  • Print the bonus on the second line as "Bonus: $<amount>".
  • productivity is not used in this version. It is there for the next versions, where you will compare employees by productivity.

Dividing two int values drops the fraction, so salary * 15 / 100 is already rounded down: int bonus = salary * 15 / 100;

Chain the text and the number with <<: cout << "Bonus: $" << bonus << endl;

string name = "John Doe";
int productivity = 83;
int salary = 135000;

int bonus = salary * 15 / 100;
cout << name << endl;
cout << "Bonus: $" << bonus << endl;

STEP 1 OF 3
    Ctrl + Enter to check