You are on page 1of 4

Write a Java application using NetBeans Integrated Development Environment (IDE) that calculates the

total annual compensation of a salesperson. Your program will work with the console, rather than
providing a Graphic user interface (GUI).Do not use a package statement in your program. Consider the
following factors:

A salesperson will earn a fixed salary of $38,000.

In addition, the salesperson will receive a commission as a sales incentive. Commission is a
percentage of the salespersons annual sales. The current commission is 5.2% 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 applications 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.
/**
*

Class: PRG420
Instructor: Professor Name Here
Creation Date: Creation Date Here

*/


import java.util.Scanner;
import java.text.NumberFormat;

class SalesPerson {

private final double fixed_Salary = 38000.00;
private final double commission_Rate = 5.2;

private double annual_Sales;

//Default Constructor
public SalesPerson() {
annual_Sales = 0.0;
}

//Parameterized Constructor
public SalesPerson(double aSale) {
annual_Sales = aSale;
}

//Get Method: Annual Sales
public double getAnnualSales(){
return annual_Sales;
}

//Method: Set Value, Annual Sales
public void setAnnualSales(double aSale) {
annual_Sales = aSale;
}

//Method: Calculate Commission
public double commission (){
return annual_Sales * (commission_Rate/100.0);
}

//Metho: Get Calculates Annual Salary
public double annualCompensation (){
return fixed_Salary + commission();
}

}

public class SalesPayComputations {

public static void main(String args[]){

//Create object of scanner class for input
Scanner input = new Scanner(System.in);

//Creats SalesPerson Class Object
SalesPerson sales_Person = new SalesPerson();

//User Entry: Annual Sales
System.out.print("Enter the annual sales : ");
double sale = input.nextDouble();

//Sets Value - Annual Sale by Sales Person
sales_Person.setAnnualSales(sale);

NumberFormat nf = NumberFormat.getCurrencyInstance();

//Display
System.out.println("The total annual compensation :
"+nf.format(sales_Person.annualCompensation()));
}

}

You might also like