d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > New To Java Help > Creating Table In Java With Netbeans
123Next
Add Reply New Topic New Poll
Member
Posts: 10
Joined: Feb 17 2014
Gold: 0.00
Feb 18 2014 01:01am
I am having trouble writing a simple commission program. I could really use a tutor or just someone that I can ask questions when needed. Can anyone tell me what I am doing wrong. This is what I need to write

• A salesperson will continue to earn a fixed salary of $50,000. The current sales target for every salesperson is $100,000.

• The sales incentive will only start when 80% of the sales target is met. The current commission is 12% of total sales.

• If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is 1.5.

• 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.

Sample Table: Assuming a total annual sales of $100,000, the table would look like this:

Total Sales Total Compensation
100,000 <<Program calculated value>>
105,000 <<Program calculated value>>
110,000 <<Program calculated value>>
115,000 <<Program calculated value>>
120,000 <<Program calculated value>>
125,000 <<Program calculated value>>
130,000 <<Program calculated value>>
135,000 <<Program calculated value>>
140,000 <<Program calculated value>>
145,000 <<Program calculated value>>
150,000 <<Program calculated value>>

And this is what I have so far:

import java.util.Scanner;

public class forLoops {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

double salary=50000;
int commission;
int annualCommission = 0;
double targetSales;
double rate=0.12;
double sales = 0;
double x = 0;

Scanner keyboard = new Scanner(System.in);

System.out.print("What were your Total Sales");
sales = keyboard.nextDouble();
x = sales;

for (double x = (double) (); x<=10; x++ ){

System.out.println(x +" "+ (x*x + " "+ x*x*x ));
}

}
==========================================================================================
And this is what I first created and know that it works

package simplecommissioncalculationprogram;

/**
*
* @author Hammer's Laptop
*/
import static java.lang.reflect.Array.get;
import java.util.Scanner;

public class SimpleCommissionCalculationProgram
{

/**
* @param args the command line arguments
*/
// Fixed Annual Salary for SalesPerson

public static void main(String[] args)
{
Scanner input = new Scanner( System.in );
int sales;
int salary=50000;
int commission;
double annualCommission;
int targetSales;

double rate=0.12;


System.out.print("Enter Total Sales $" );
// This is the total annual sales
sales = input.nextInt();
// Since the total sales can differ this is input manually

System.out.println("Your Annual Salary is $" + salary);
// The annual sales are the same for every salesperson

System.out.println("Your Interest Rate is" + rate );
// The interest rate is the same for every sales person

commission = (int) (sales * rate);
System.out.println("Your Commission is" + commission);

annualCommission = commission + salary;
// Calculates total annual compensation for a salesperson
System.out.printf ("Total Annual Commission $%.2f",
get.annualCommission());
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 18 2014 02:15am
Decided to post sign up to a dieing gaming forum to ask a question instead of using stackoverflow.

Also use code tags and fix your indenting if you're serious, shits hard to read.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Feb 18 2014 05:15pm
First post, and at 2am. Something tells me you were trying to make a deadline because you waited to the last minute.

Here is an overly engineered solution to your problem
Code

public class CommissionCalculator
{
private final double ACCELERATION = 1.5;
private final double INCENTIVE = 0.80;
private final double COMMISSION = 0.12;
private double annualSales, salary, salesTarget;

public CommissionCalculator(double annualSales, double salary, double salesTarget)
{
this.annualSales = annualSales;
this.salary = salary;
this.salesTarget = salesTarget;
}

public boolean isIncentiveMet()
{
return isIncentiveMet(annualSales);
}

public boolean isIncentiveMet(double annualSales)
{
return annualSales >= (salesTarget * INCENTIVE);
}

public boolean isSalesTargetExceeded()
{
return isSalesTargetExceeded(annualSales);
}

public boolean isSalesTargetExceeded(double annualSales)
{
return annualSales > salesTarget;
}

public double calculateCommission()
{
return calculateCommission(annualSales);
}

public double calculateCommission(double annualSales)
{
double total = 0.0;
if(isIncentiveMet(annualSales))
{
total = annualSales * COMMISSION;

if(isSalesTargetExceeded(annualSales))
{
total *= ACCELERATION;
}
}

return total;
}

public double calculateTotalAnnualCompensation()
{
return calculateTotalAnnualCompensation(annualSales);
}

public double calculateTotalAnnualCompensation(double annualSales)
{
return salary + calculateCommission(annualSales);
}
}

import java.util.Scanner;

public class Driver
{
private final double SALARY = 50000.0;
private final double SALES_TARGET = 100000.0;
private final double INCREMENT = 5000.0;
private final double CAP = 0.50;

private Scanner in;

public Driver(Scanner in)
{
this.in = in;
}

private double getAnnualSales()
{
double annualSales;

System.out.println("Enter annual sales: ");
annualSales = in.nextDouble();

return annualSales;
}

private void printPotentialTotalAnnualCompensationTable(double annualSales, CommissionCalculator calc)
{
System.out.println("Total Sales\tTotal Compensation");
for(double sales = annualSales; sales <= annualSales * (1+CAP); sales += INCREMENT)
{
System.out.println(sales +"\t" + calc.calculateTotalAnnualCompensation(sales));
}
}

public void run()
{
CommissionCalculator calc;
double annualSales;

annualSales = getAnnualSales();
calc = new CommissionCalculator(annualSales, SALARY, SALES_TARGET);
printPotentialTotalAnnualCompensationTable(annualSales, calc);
}

public static void main(String[] args)
{
Scanner in;
Driver d;

in = new Scanner(System.in);
d = new Driver(in);

d.run();
}

}
Member
Posts: 10
Joined: Feb 17 2014
Gold: 0.00
Feb 18 2014 10:44pm
Thank You so much for your help.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Feb 18 2014 10:48pm
I'm shocked you showed up again.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 19 2014 01:49am
Quote (carteblanche @ Feb 19 2014 12:48am)
I'm shocked you showed up again.


I'm shocked he would register to this forum to ask a question.
Member
Posts: 10
Joined: Feb 17 2014
Gold: 0.00
Feb 22 2014 04:17am
I am new to this forum and was recommended to it by a friend since I am new to programming. So I appreciate the advice. Which brings me to my new question. The application must compare the total annual compensation of at least two sales person. It also needs to calculate the additional amount of sales that each salesperson much achieved to match or exceed the higher of the two eaners. The application should ask for the name of each salesperson being compared. This must demonstrate the jse of array or array list
Member
Posts: 1,241
Joined: Jun 25 2011
Gold: Locked
Feb 22 2014 05:39am
Quote (Hammertime1979 @ Feb 22 2014 12:17pm)
I am new to this forum and was recommended to it by a friend since I am new to programming. So I appreciate the  advice. Which brings me to my new question. The application must compare the total annual compensation of at least two sales person. It also needs to calculate the additional amount of sales that each salesperson much achieved to match or exceed the higher of the two eaners. The application should ask for the name of each salesperson being compared. This must  demonstrate the jse of array or array list


And? Is there anything specific you dont know how to do?
Member
Posts: 10
Joined: Feb 17 2014
Gold: 0.00
Feb 22 2014 06:12pm
I am trying to create an Array List that alllows me to display employeesName and there annualSalary. I know how to create a basic Array but am a little confused on this.
Member
Posts: 10
Joined: Feb 17 2014
Gold: 0.00
Feb 22 2014 06:19pm
public class AnnualSalesComparison

{
public static void main(String[] args )
{
String lookupEmployees;

String[] employees = { "Collins, Jeff", "Smith, Bill", "Sledge, Eric",
"Sledge, Willam", "Wilson, George"
};
Scanner keyboard;
keyboard = new Scanner (System.in);

System.out.print ( "Enter the first few characters of " +
"the last name to look up:");

lookupEmployees = keyboard.nextLine();

System.out.println("Here are the employees with the top sales:");

for (String topEarners : employees)
{

if (topEarners.startsWith (lookupEmployees))
{
System.out.println (topEarners);
}
}


}

}

This is all that I have so far any advice is greatly appreciated.
Go Back To Programming & Development Topic List
123Next
Add Reply New Topic New Poll