Sales Commission Program

I'm wanting my program to account for users that input their own random commission rate or quarterly sales. What would I need to change to make my program account for random inputs? For example, my current code would return the input of 3202.65 with a result of 160.13, which is expected, but it then returns the input of 48627.61 with a result of 4403.03 when I'm wanting it to return 3003.93. I know I could change the math around to get that specific output but I'm wanting it to account for random inputs from users as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
#include <iomanip>

using namespace std;

int main()
{
    double quarterlySales = 0;
    double commissionRate = 0;

    cout << "Please enter quarterly sales: $";
    cin >> quarterlySales;

    if (quarterlySales > 0 && quarterlySales <= 20000)
        (commissionRate = quarterlySales * 0.05);
    else if (quarterlySales >= 20001 && quarterlySales < 50001)
        (commissionRate = quarterlySales * 0.07 + 1000);
    else if (quarterlySales >= 50001)
        (commissionRate = quarterlySales * 0.1 + 3100);
    else if (quarterlySales < 0)
        cout << "!Error!";
    else
        (commissionRate = 0);

    cout << "\nQuarterly sales are: $" << setprecision(2) << fixed << quarterlySales;
    cout << "\nCommision is: " << setprecision(2) << fixed << commissionRate;

    return 0;
}
Yes, but do you happen to know of a solution to my problem?
Topic archived. No new replies allowed.