daisies you Java. Okay, I have a Java program I'm writing for homework and there's just one error left for me to fix, except it's not a technical error so Netbeans thinks there's nothing wrong.
The goal is to input imaginary sales for a salesperson, calculate their commission (if any), then output their commission + fixed salary for a total. The sales also need to be shown on a table in $5,000 increments above the actual, capped at 150% of the actual, that shows the potential totals of those increments. This is where the problem is. The table shows up and so do the tiers of sales, but the totals remain the same no matter what. I'll try showing the code I have to see if anyone can figure out what I'm doing wrong.
Code:
import java.util.*;
public class Calculator {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//Scanner class imported to utilize keyboard input.
double fixedSalary = 100_000;
double annualSales;
double commissionValue;
double commissionRate = .05;
double salesTarget = 120_000;
double salesBegin = 96_000;
double totalCompensation;
double maximumAnnualSales;
double maximumCompensation;
//Variable names describe what they represent clearly.
System.out.print("Enter salesperson's total annual sales: $");
annualSales = input.nextDouble();
//User inputs the amount of sales the salesperson has made.
while (annualSales < 0 || annualSales > 99999999)
{
System.out.println("Invalid input.");
System.out.println();
System.out.print("Enter salesperson's total annual sales: $");
annualSales = input.nextDouble();
//If the input is invalid the user is notified and prompted
//to enter valid input.
}
if (annualSales >= salesBegin && annualSales < salesTarget) {
commissionValue = (annualSales * commissionRate);
//If the sales are over 80% of the sales target but don't meet it
//then the sales incentive executes.
}
else if (annualSales >= salesTarget) {
commissionValue = ((annualSales * commissionRate) * 1.25);
//If the sales meet or exceed the sales target it adds on
//the acceleration factor to the output.
}
else commissionValue = 0;
//If no conditions are met then there is no commission.
totalCompensation = fixedSalary + commissionValue;
//Final total
System.out.println("Salesperson's total annual compensation is: "
+ "$"
+ totalCompensation
);
//The program outputs the total annual compensation of the salesperson.
System.out.println();
//Blank line to separate from the total.
System.out.println("Total Possible Sales \t Total Possible Annual Compensation" );
maximumAnnualSales = annualSales * 1.5;
//Maximum potential sales are 150% of actual.
do {
System.out.println("$" + annualSales
+ "\t\t" + "$" + totalCompensation);
annualSales = annualSales + 5000;
}
while (annualSales <= maximumAnnualSales);
//Loop takes annual sales and projects to 1.5 times the amount. Intention
//is for annual compensation to do the same but the table shows identical
//values and I can't figure out why since there are no explicit errors.
}
}