Monique_2 0 Newbie Poster

Part 2 to Salesperson Java Application, still new to this.

class SalesPerson {

/**
 * Fixed Salary
 */
final double fixedSalary = 35000;
/**
 * Current Commission Rate
 */
public double curCommissionRate = 0.15;
/**
 * Accrued Commission
 */
public double curCommission = 0;
/**
 * Total Compensation
 */
public double totalCompensation = 0;
/**
 * Annual Sales
 */
public double annualSales = 0;

/**
 * Parameterized Constructor
 *
 * @param annualSales The Salesperson's annual sales.
 */
public SalesPerson(double pAnnualSales) {
    annualSales = pAnnualSales; //set object member
    curCommission = (annualSales * curCommissionRate); //calculate current commission

    totalCompensation = fixedSalary + curCommission;
}
}

class Utils {

public static String numFormat(double dec) {
    return new DecimalFormat("##,##0.00").format(dec);
}

public static double getDoubleJob(String message) {
    double goodJob = 0; //What we want to validate and return.
    try { //Try so we can catch exceptions.
        System.out.print(message); //Print message.

        //This will throw the exception if input is non double:
        goodJob = Double.parseDouble(new Scanner(System.in).nextLine());
    } catch (NumberFormatException ex) { 

        System.out.println("Sorry. Please enter numbers only.");
        goodJob = getDoubleInput(message);
    }

    return goodJob;

  }
  }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.