I have been working on a project for my course. It's a simple salary calculator, which I have figured out fairly easily and it functions flawlessly. It also takes into consideration benchmarks for commission. I have completed choped on the last part, however. I cannot get it to function. It either loops indefinitely, or it generates static numbers under the "Total Compensation" column (they should be dynamic based on commission etc).
- Bob makes $85,000 a year.
- He gets no bonus/commission if he sells less than $120,000
- He gets 15% commission if his sales for the year are >= $120,000
- He gets an additional 2% for every $150k in sales (150k, 300k, 450k etc)
User inputs a sales number (example: $300,000). Program calculates BaseSalary + ($300,000 * .15) + ($300,000 * .02)
Potential Sales on the left and then Total Compensation on the right side
200,000 ----------------------> (Calculated)
220,000 ----------------------> (Calculated)
240,000 ----------------------> (Calculated)
260,000 ----------------------> (Calculated)
280,000 ----------------------> (Calculated)
300,000 ----------------------> (Calculated)
//Variables defined here
double Sales = input.nextDouble();
double TotalCompensation;
int Commission;
double CommissionRate;
double AcceleratedCommissionRate;
int BaseSalary;
double TargetSales;
double Accelerator;
double AcceleratorGoal;
double AcceleratedCommission;
// Mathematical Operations
Accelerator = 0.80;
TargetSales = 150000;
CommissionRate = 0.15;
AcceleratedCommissionRate = ((CommissionRate) * (2.0));
BaseSalary = 85000;
Commission = (int) (Sales * CommissionRate);
AcceleratedCommission = (double) (Sales * AcceleratedCommissionRate);
AcceleratorGoal = (double) 120000;
// If Else Logic Flow
if(Sales < AcceleratorGoal)
{
TotalCompensation = BaseSalary;
System.out.print("\nCommission Goal HAS NOT been met");
System.out.println("\nTotal annual compensaton is: ");
System.out.println(numberFormat.format(TotalCompensation));
}
else if(Sales < TargetSales)
{
TotalCompensation = BaseSalary + Commission;
System.out.print("\nCommission Goal HAS been met");
System.out.println("\nTotal annual compensaton is: ");
System.out.println(numberFormat.format(TotalCompensation));
}
else if(Sales >= TargetSales)
{
TotalCompensation = BaseSalary + AcceleratedCommission;
System.out.print("\nAccelerator Goal HAS been met");
System.out.println("\nTotal annual compensaton is: ");
System.out.println(numberFormat.format(TotalCompensation));
}
// Potential Commission Structure Table
double PotentialSales;
double EndLoop = (Sales * 1.5);
int Increment = 20000;
System.out.println("\nPotential Sales\t\tTotal Compensation");
for (PotentialSales = Sales; PotentialSales < EndLoop;
PotentialSales = PotentialSales += Increment)
{
do
{
String output = numberFormat.format(PotentialSales) + "\t\t"
+ numberFormat.format(BaseSalary);
System.out.println(output);
}
while(PotentialSales < AcceleratorGoal);
do
{
String output = numberFormat.format(PotentialSales) + "\t\t"
+ numberFormat.format(Commission + BaseSalary);
System.out.println(output);
}
while(PotentialSales >= AcceleratorGoal && PotentialSales < TargetSales);
do
{
String output = numberFormat.format(PotentialSales) + "\t\t"
+ numberFormat.format(AcceleratedCommission + BaseSalary);
System.out.println(output);
}
while(PotentialSales >= TargetSales);
}
Any suggestions or tips whatsoever would be a lifesaver.
Aucun commentaire:
Enregistrer un commentaire