32.6k views
3 votes
What will be the value of bonus after the following statementsare executed?int bonus, sales = 10000;if (sales < 5000)bonus = 200;else if (sales < 7500) bonus = 500;else if (sales <10000)bonus 750; else if (sales < 20000)bonus 1000;elsebonus 1250;O 750O 1250O 500O 1000

1 Answer

3 votes
Based on the code provided, the value of bonus will be 750 since the value of sales is 10000, which falls between the range of 7500 and 20000. Therefore, the else if (sales < 10000) condition is false, and the else if (sales < 20000) condition is true, causing the value of bonus to be set to 1000. However, there is a typo in the code where the assignment operator is missing after bonus in the fourth else if statement. It should be:

else if (sales < 20000)
bonus = 1000;

Assuming that this typo is fixed, the final value of bonus will be 750.
User Miroslav Michalec
by
9.6k points