posted 1 year ago
This code gives the following output. It works I am just banging my head up against the wall trying to figure out why the annual compensation is so high. I can't figure it out. Any help, suggestions would be eternally grateful!!
run:
What are the total sales?
150000
Your annual income is: $75000.0
If sales target is met compensation is below
$114,375.00 is what you made this year
Sales Total Total Annual Compensation

Sales: 150000.0 Annual Compensation: 228750.0
Sales: 155000.0 Annual Compensation: 228750.0
Sales: 160000.0 Annual Compensation: 228750.0
Sales: 165000.0 Annual Compensation: 228750.0
Sales: 170000.0 Annual Compensation: 228750.0
Sales: 175000.0 Annual Compensation: 228750.0
Sales: 180000.0 Annual Compensation: 228750.0
Sales: 185000.0 Annual Compensation: 228750.0
Sales: 190000.0 Annual Compensation: 228750.0
Sales: 195000.0 Annual Compensation: 228750.0
Sales: 200000.0 Annual Compensation: 228750.0
Sales: 205000.0 Annual Compensation: 228750.0
Sales: 210000.0 Annual Compensation: 228750.0
Sales: 215000.0 Annual Compensation: 228750.0
Sales: 220000.0 Annual Compensation: 228750.0
BUILD SUCCESSFUL (total time: 5 seconds)
 1
This code gives the following output. It works I am just banging my head up against the wall trying to figure out why the annual compensation is so high. I can't figure it out. Any help, suggestions would be eternally grateful!!
run:
What are the total sales?
150000
Your annual income is: $75000.0
If sales target is met compensation is below
$114,375.00 is what you made this year
Sales Total Total Annual Compensation

Sales: 150000.0 Annual Compensation: 228750.0
Sales: 155000.0 Annual Compensation: 228750.0
Sales: 160000.0 Annual Compensation: 228750.0
Sales: 165000.0 Annual Compensation: 228750.0
Sales: 170000.0 Annual Compensation: 228750.0
Sales: 175000.0 Annual Compensation: 228750.0
Sales: 180000.0 Annual Compensation: 228750.0
Sales: 185000.0 Annual Compensation: 228750.0
Sales: 190000.0 Annual Compensation: 228750.0
Sales: 195000.0 Annual Compensation: 228750.0
Sales: 200000.0 Annual Compensation: 228750.0
Sales: 205000.0 Annual Compensation: 228750.0
Sales: 210000.0 Annual Compensation: 228750.0
Sales: 215000.0 Annual Compensation: 228750.0
Sales: 220000.0 Annual Compensation: 228750.0
BUILD SUCCESSFUL (total time: 5 seconds)
Jason Patton
Greenhorn
Posts: 4
posted 1 year ago
The current sales target for every salesperson is $140,000.
The sales incentive will only start when 80% of the sales target is met. The current commission is 25% of total sales.
If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is 1.25.
The application should ask the user to enter annual sales, and it should display the total annual compensation.
The application should also display a table of potential total annual compensation that the salesperson could have earned, in $5000 increments above the salesperson's annual sales, until it reaches 50% above the salesperson's annual sales.
Anything less than 112000 does not receive commission. Between 112,000 and 139,999 does receive 25%
Knute Snortum wrote:What is the formula for annual compensation in nonprogramming terms?
The current sales target for every salesperson is $140,000.
The sales incentive will only start when 80% of the sales target is met. The current commission is 25% of total sales.
If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is 1.25.
The application should ask the user to enter annual sales, and it should display the total annual compensation.
The application should also display a table of potential total annual compensation that the salesperson could have earned, in $5000 increments above the salesperson's annual sales, until it reaches 50% above the salesperson's annual sales.
Anything less than 112000 does not receive commission. Between 112,000 and 139,999 does receive 25%
Jason Patton
Greenhorn
Posts: 4
posted 1 year ago
Look again.Jason Patton wrote:
Knute Snortum wrote:Let's look at the code you wrote to calculate commision.
What happens if the sales is 100000?
Nothing because there is no commission at that point. Anything below 112,000 gains 0 commission.
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
Jason Patton
Greenhorn
Posts: 4
posted 1 year ago
Ok so now I changed the statements to look like this:
if (sales <=112000) //defines parameters for amount of sales
{
commission = 0.0;
}
else if (sales >= 112000 && sales < 140000) //continues to define parameters for amount of sales.
{
commission = 0.25;
}
else if (sales > 140000)
{
commission = 0.2625; //declares what to do if either parameter above is not met.
}
else
}
income = 75000;
{
But that has not changed the outcome of my table whatsoever!
Knute Snortum wrote:Hint: there are two ifstatements, not one.
Ok so now I changed the statements to look like this:
if (sales <=112000) //defines parameters for amount of sales
{
commission = 0.0;
}
else if (sales >= 112000 && sales < 140000) //continues to define parameters for amount of sales.
{
commission = 0.25;
}
else if (sales > 140000)
{
commission = 0.2625; //declares what to do if either parameter above is not met.
}
else
}
income = 75000;
{
But that has not changed the outcome of my table whatsoever!
posted 1 year ago
Jason, try the way to start from the largest commision, you should be able to come up with less complex structure of ifthenelse statements.
i.e.:
i.e.:
posted 1 year ago
Outside of the if statement, there is an issue with your calculation:
The second one is inside the loop with the increasing salesTarget.
Note that you are using sales in there and not salesTarget, so the calculation will always be the same.
However, also note that compensation calculation, so the latter one can be rewritten:
Now that doesn't look correct to me...
The second one is inside the loop with the increasing salesTarget.
Note that you are using sales in there and not salesTarget, so the calculation will always be the same.
However, also note that compensation calculation, so the latter one can be rewritten:
Now that doesn't look correct to me...
posted 1 year ago
Sorry to appear a pedantic so‑and‑so, but you have two options for 112000. Look at lines 1 and 5 in Paul C's post. And you have no option for exactly 140000. You won't notice the two occurrences of 112000 because of the else, but things will go horribly wrong if you sell exactly 140000. I like to write if‑elses in order, either ascending or descending, depending on what you do with the boundary values. I also try to use < or > rather than >=/≥ or <=/≤ because the former two are usually easier to read.I think that format is easier to read, and also, if you stick to one operator, there is no risk of missing out values like 140000.
Ruth Stout was famous for gardening naked. Just like this tiny ad:
The WEB SERVICES and JAXRS Course
https://coderanch.com/t/690789/WEBSERVICESJAXRS
