Hi I am new to Java/netbeans. I have been working on a school assignment to create a commission calculator. I have it done I believe but, have some errors. Please help.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package commission.calculator;

/**
 *
 * @author Chewi_000
 */
import java.util.Scanner;

public class CommissionCalculator {
 /**
  * @param args the command line arguments
  */
  // This is the beginning of the main method
 public static void main(String[] args) {
  // This method displays the salespersons fixed annual salary
   fixedSalary = 100,000;
  // This method displays the salespersons commission rate
   int commission;
   commission = 2.5;
   commissionCalc = totalSales * .025;
   System.out.println("The total sales of the salesperson is $";
                       + commissionCalc + " using a 2.5% commission.");

// Creates Scanner to collect total sales input from salesperson
  Scanner input = new Scanner(System.in);
  double totalSales; // Salespersons total sales
  System.out.print("Enter total sales:  ");
  totalSales = input.nextDouble();

  double commissionCalc; // Calculates commission of total sales
  commissionCalc = totalSales * .025;

  System.out.println(The total sales of the salesperson is $"
                      + commissionCalc + " using a 2.5% commission.");

  double totalfixedsum; // Salespersons total fixed compensation
  totalFixedSum = fixedSalary + commisionCalc;
  System.out.println("The total fixed compensation of the salesperson "
                    + "is:  $" + totalFixedSum + ".");

  } // end main method
} // end class CommissionCalculation

Edited 2 Years Ago by __avd: format code

  • Ok Change line 21 to

    double fixedSalary = 100000;

Reason: Type of variable not declared also a syntax error, you can't add any character such as "," in type int, double or float and it's unnecessary.

  • line 23

    double commission;

Reason: since it's a fraction number (2.5) you should use type double or float

  • delete line 25,26 and 27
    Reason: logic + syntax error, if you notice you repeating the same code twice so delete the above code because you didn't declared its variables

  • line 36

    commissionCalc = totalSales * (commission/10);

Reason: logic error, you didn't use the commission, it's a waste of memory, so make use of it.

  • lines 38 and 39

    System.out.println("The total sales of the salesperson is $"
    + commissionCalc + " using a 2.5% commission.");

Reason: syntax error, missing quote.

  • in line 42 change commisionCalc to commissionCalc and totalFixedSum to totalfixedsum also in line 44
    Reason: Java is case sensitive, you should match what you wrote at first.

and that's it you are good to go.

I will guys thank you so much. I spent hours on that and I am sure others have it done quick.

This question has already been answered. Start a new discussion instead.