Problem #34
Solution Source Code
Code Overview
1. Header Files and Namespace:
-
<iostream>is included for input and output operations. -
<string>is included for potential future use (not used in this program). -
using namespace std;allows the use of standard functions without prefixing them withstd::.
2. User Input Function (ReadTotalSales)
- Prompts the user to enter the total sales amount.
- Reads and returns the value as a float.
3. Commission Calculation Function (GetCommissionPercentage)
- Takes the total sales amount as input.
- Determines the commission percentage based on sales brackets:
-
≥ 1,000,000 →
1% -
500,000 - 999,999 →
2% -
100,000 - 499,999 →
3% -
50,000 - 99,999 →
5% -
Below 50,000 →
0%
-
≥ 1,000,000 →
- Returns the commission percentage.
4. Total Commission Calculation Function (CalculateTotalCommission)
- Uses the commission percentage to compute the total commission amount: Total Commission=Total Sales×Commission Percentage\text{Total Commission} = \text{Total Sales} \times \text{Commission Percentage}Total Commission=Total Sales×Commission Percentage
- Returns the computed total commission.
5. Program Execution (main())
- Calls
ReadTotalSales()to get user input. - Calls
GetCommissionPercentage()to determine the commission rate. - Calls
CalculateTotalCommission()to compute the commission amount. - Prints the commission percentage and total commission.
- Returns
0to indicate successful execution.
This structured explanation ensures clarity and ease of understanding.
17 comments