Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

The company has recently changed its total annual compensation policy to improve sales. A salesperson will continue to earn a fixed salary of $12,000....

  • The company has recently changed its total annual compensation policy to improve sales.
  • A salesperson will continue to earn a fixed salary of $12,000. The current sales target for every salesperson is $120,000.
  • The sales incentive will start only when 80% of the sales target is met. The current commission is 7% of total sales. For example, if my target is $120,000, 80% of that is $96,000. If I sell $95,000, I get no commission. If I sell $96,000, I get 7% of that amount.
  • If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is 1.25. If my target is $120,000 and I sell $120,000, my commission is 7% of that amount. If I sell $121,000, then my commission is 7% of $120,000, PLUS (7% of $1,000 multiplied by 1.25).
  • The application should ask the user to enter the annual sales amount, and it should display (like last week) the commission amounts (regular and accelerated), salary, commission rate, and the total annual compensation.
  • The main() method in the application should also display a table of potential total annual compensation that the salesperson could have earned, in $5,000 increments above the salesperson's annual sales, until it reaches 50% above the salesperson's annual sales. The table should start at the current total sales.

Sample Table: Assuming a total annual sales of $98,765.43 (but your table will use different values for total sales; the number used here is just an assumption), the table would look like this:

Total Sales

Total Compensation

98,765.43

<<Program calculated value>>

103,765.43

<<Program calculated value>>

108,765.43

<<Program calculated value>>

113,765.43

<<Program calculated value>>

118,765.43

<<Program calculated value>>

123,765.43

<<Program calculated value>>

128,765.43

<<Program calculated value>>

133,765.43

<<Program calculated value>>

138,765.43

<<Program calculated value>>

143,765.43

<<Program calculated value>>

Program Organization

  • You are not allowed to use any static variables. Your main() method is static, and that's okay.
  • The calculation of the commission will now take place in a separate class, described in the next section.

CommissionCalculator class

  • The application must now have a second class (and .java file). Name it CommissionCalculator. This second class should contain all of the commission calculations. Your current, existing class (CommissionCalculatorApp) will use this new class to do its commission calculations (instead of doing them itself). So, you'll want to move your current commission calculations (where you multiply sales by commission rate to yield commission amount) to this new class, and modify your existing class (CommissionCalculatorApp) to use the new class you're going to create.
  • That class should probably have fields for the commission rate, the acceleration factor, and so on. It should probably also have a method called CalculateCommission, which takes a sales amount as an argument. It would multiply that amount by the rate and return the commission amount. (If all this sounds like gobbledy-gook, ask questions in class!)
  • Your new CommissionCalculator class may not have a main() method.
  • The class must have a constructor that takes several arguments, representing various values that the new object will need to calculate the commission. For example, the commission rate or percentage, the acceleration rate, the target amount, and so on.
  • Your CommissionCalculator class is not allowed to have any numerical literal values in it. For example, the value "0.07" cannot appear in the CommissionCalculator class. So where do these values come from? The CommissionCalculatorApp must pass them to the CommissionCalculator object in the CommissionCalculator's constructor. So, the various literal values that come to mind are 0.07, 1.25, 0.8, 120000.0. Any others?
  • Your CommissionCalculator class cannot have any public variables/fields in it. It can, and should, have public methods.
  • Your week 2 project and class are called CommissionCalculatorApp (the "App" at the end stands for "application"). That class has a "main()" method in it. Currently, from week 2, the code in main() assigns annual sales, performs some calculations, and displays the results of the applications. This week you must take the commission calculation out of main() and put it into a method in CommissionCalculator (not CommissionCalculatorApp).
  • So, you should modify your main() method to 1) open a new CommissionCalculator object (using the "new" keyword), 2) prompt the user for input, such as total annual sales, 3) use the new object you just created to calculate the commission (by calling that object's "CalculateCommission()" method), 4) in your main() method, calculate total annual compensation, etc., 5) in your main() method, display the results of the calculations, and 6) in your main() method, calculate values for the table and display those values in table format.
  • The additional class must have member variables (such as the commission rate already mentioned; any others come to mind?). Remember, your CommissionCalculator class cannot have literal values such as 0.8, 120000.0, 1.25, and so on. Also, it cannot have any public field/variables.
  • The additional class is not allowed to display anything.
  • The additional class is not allowed to input/read anything from the keyboard.
  • The additional class is not allowed to refer to any variables in the CommissionCalculatorApp class by name. This means that the only variables the CommissionCalculator class can use are 1) its own variables, 2) automatic variables, and 3) methods can refer to their arguments.
  • The additional class is not allowed to calculate total compensation.

Input

  • This week you must prompt the user for input (the annual sales), then read the user's input. This should be a matter of 1) displaying a prompt (using System.out.println()), such as "Enter annual sales: ", and 2) reading the next value from the keyboard. See the Scanner class for information on reading in values.
  • When I test/run your program I might enter negative numbers, or 0 when asked to input data (such as annual sales). Your program should check for that, complain if it finds a problem, and ask again (and ask again and again, until I enter valid data). You have to determine if the number is valid. For example, is 0 a valid number when entering annual sales? Is -1000?
  • When I test/run your program I will not enter data that might cause your program to crash. For example, if you ask for a number, I will always enter a number; I won't enter "xyz."
  • When you ask for annual sales, I will input just a number, possibly with a decimal point and cents. I will not input a dollar sign nor will I enter a comma.

Calculations

  • The main() method is not allowed to calculate the commission amount directly; it must call the new CommissionCalculator object to do that (see above). It must, however, calculate the total annual compensation.
  • Use parentheses to explicitly specify the order of operations. Ask questions if you have any.

Output

  • You must display money values (currency) with a dollar sign ($) and exactly two decimal places. You need not use commas.
  • The table above doesn't need borders, etc. You just need to display two columns of numbers, with a header (Total Sales Total Compensation).
  • None of the primitive types (float/double/int/etc.) store just 'n' decimal places. The float and double store as many as they can. So, the technique is to format your variable value when you print it out. There are several around, and one that's pretty standard and easy to use it the DecimalFormat class. Google it, "Java DecimalFormat." You can copy/paste any code you find and understand, but only for the DecimalFormat usage.
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question