0

I wrote the program up, but I'm getting all types of errors. Which I'm new to this whole Java Application class. I keep getting errors :
Please help.

  1. employee is not defined.
  2. NewSalesPerson is not defined.
  3. UtilnumFormat is not defined.
  4. Variable declaration not allowed here.
  5. error: ';' expected.
  6. reached end of the file while parsing.

    import java.text.DecimalFormat; //used to format currency
    import java.util.Scanner; //used for the scanner

    /*Write a Javaâ„¢ application using jGRASPâ„¢ Integrated
    Development Environment (IDE) that calculates the total annual
    compensation of a salesperson. Consider the following factors:
    A salesperson will earn a fixed salary of $35,000.
    A salesperson will also receive a commission as a sales
    incentive. Commission is a percentage of the salesperson’s

    • annual sales. The current commission is 15% of total sales.
      The total annual compensation is the fixed salary plus the
      commission earned.
      The Javaâ„¢ application should meet these technical requirements:
      The application should have at least one class, in addition to the
      application’s controlling class (a controlling class is where the
      main function resides).
      There should be proper documentation in the source code.
      The application should ask the user to enter annual sales, and it
      should display the total annual compensation.*/

    /*

    • @author Monique
      */
      public class Compensation{

      private static SalesPerson employee;
      // SALESPERSON Object
      Scanner user_input=newScanner(System.in); // input as a Scanner object (used for keyboard monitoring)
      public static void main(String[] args);{

      double annualSalary;

      System.out.println("Salesperson Annual Compensation Calculator");

      System.out.print1n("Please enter the employee's annual sales:");
      annualSalary=myScanner.nextDouble();

      employee = newSalesPerson(user_Input);

      System.out.println("Salesperson information:");

      System.out.println("Fixed Salary: $" + UtilsnumFormat(employee.fixedSalary);

      System.out.println("Annual Sales: $" + UtilsnumFormat(employee.annualSales);

      System.out.println("Current Commission: $" + UtilsnumFormat(employee.curCommission);

      System.out.println("Current Commission Rate: " +(employee.curCommissionRate*100+ "%");

      System.out.println("Total Annual Compensation: $" + UtilsnumFormat(employee.totalCompensation);

      System.out.println("Enter Y to reset. Anything else to quit.");

      if (input.next(),toLowerCase(),equals("y")) {
      main(args);
      }

    }

I keep getting errors :

  1. employee is not defined.
  2. NewSalesPerson is not defined.
  3. UtilnumFormat is not defined.
  4. Variable declaration not allowed here.
  5. error: ';' expected.
  6. reached end of the file while parsing.
2
Contributors
1
Reply
12
Views
9 Months
Discussion Span
Last Post by JamesCherrill
1

Some basics:
Everything you use in Java must have been declared. You try to use a variable employee but you have not defined it anywhere.
Spelling, including upper/lower case must be exactly correct... print1n is not the same as println
Punctuation in Java has to exactly correct all the time, so UtilnumFormat is not the same as Util.numFormat. Similarly , is not the same as .
Every open bracket has to have a matching close bracket. Your code has 3 open brackets bit only 2 close brackets, so obviously they cannot match.

The reason Java is so absolutely picky is that it's quicker and cheaper to find and fix errors at compile time than at run time. Java will reject the slightest error in your program just as soon as it sees it, and that takes some getting used to. But it's for your own good. Most of your errors are just careless spelling and punctuation, so they are easy to fix.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.