How do I use a nested if statement to calculate an employee’s productivity bonus and print the employee’s name and bonus? Bonuses are calculated based on an employee’s productivity score as shown below. A productivity score is calculated by first dividing an employee’s transactions dollar value by the number of transactions and then dividing the result by the number of shifts worked. Productivity Score Bonus <=30 $50 31–69 $75 70–199 $100 >= 200 $200
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
How do I use a nested if statement to calculate an employee’s productivity bonus and print the employee’s name and bonus? Bonuses are calculated based on an employee’s productivity score as shown below. A productivity score is calculated by first dividing an employee’s transactions dollar value by the number of transactions and then dividing the result by the number of shifts worked.
Productivity Score | Bonus |
---|---|
<=30 | $50 |
31–69 | $75 |
70–199 | $100 |
>= 200 | $200 |
![EmployeeBonus.cpp
10
9 string employeeFirstName;
string employeeLastName;
double numTransactions;
11
12
double numShifts;
13
double dollarValue;
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
double score;
double bonus;
const double BONUS_1 = 50.00;
const double BONUS_2 = 75.00;
const double BONUS_3 = 100.00;
const double BONUS_4 = 200.00;
cout << "Enter employee's first name: ';
cin>>employeeFirstName;
cout << "Enter employee's last name: ";
cin>>employeeLastName;
cout << "Enter number of shifts: ";
cin >> numShifts;
cout << "Enter number of transactions: ";
cin >> numTransactions;
cout << "Enter dollar value of transactions: ";
dollarValue;
cin
// Write your code here](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F297e17a6-e808-458b-a2da-d42538e4edb6%2F72fc0565-c6db-46d7-ae57-7bc203c9888a%2F72xqydc_processed.png&w=3840&q=75)
![Employee Bonus.cpp
34
#include<iostream>
35 using namespace std;
36 int main()
37 {
38 int
39 int
40 int BONUS_3 = 70-199;
41 int BONUS_4 = 200
42
43 if (BONUS_1 <= 30) { // first if condition : variable BONUS_1 is checked
44 cout << " value of BONUS_1 is: " << 50.00 << endl;
45
46 if ( BONUS_2 = 31-69) { // second if condition : variable BONUS_2 is checked
47 cout <<
11
" value of BONUS_2 is: << 75.00 << endl;
BONUS_1 = 30; // Declare and assign values to variables
BONUS_2 = 31-69;
48}
49 }
50 return 0;
51 }
52
53
54
55
56
57
5
// This is the work done in the endOfJob() function
// Output.
cout << "Employee Name: " << employeeFirstName << " " << employeeLastName
cout << "Employee Bonus: $" << bonus << endl;
return 0;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F297e17a6-e808-458b-a2da-d42538e4edb6%2F72fc0565-c6db-46d7-ae57-7bc203c9888a%2Fhp6jtjg_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)