Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a console based, non-GUI Java application using NetBeans Integrated Develo

ID: 3838358 • Letter: W

Question

Write a console based, non-GUI Java application using NetBeans 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 $24000 per year. 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 4.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 application's controlling class (a controlling class is where the main function resides). The application source statements should reside in exactly one .java file and contain no package statement.

(see Java Project Without Packages, posted in Class Messages.) Application must avoid all posted avoidances. (see Avoidances for PRG/420, posted in Class Messages). There should be proper documentation in the source code, including a comment at the top of the source file, containing the name of the course, your name, the week number, and the date. The application should ask the user to enter annual sales, and it should display the total annual compensation.

Explanation / Answer

/**
* Name of the course:
* Name:
* Week number:
* Date:
*
*/

/**
* @author
*
*/
public class SalesPerson {

   private int id;
   private String name;
   private double anualSalary;
   private double totalSales;
   private double commisionRate;

   public SalesPerson() {
       // TODO Auto-generated constructor stub
   }

   /**
   * @param id
   * @param name
   * @param anualSalary
   * @param totalSales
   * @param commisionRate
   */
   public SalesPerson(int id, String name, double anualSalary,
           double totalSales, double commisionRate) {
       this.id = id;
       this.name = name;
       this.anualSalary = anualSalary;
       this.totalSales = totalSales;
       this.commisionRate = commisionRate;
   }

   /**
   * @return the id
   */
   public int getId() {
       return id;
   }

   /**
   * @return the name
   */
   public String getName() {
       return name;
   }

   /**
   * @return the anualSalary
   */
   public double getAnualSalary() {
       return anualSalary;
   }

   /**
   * @return the totalSales
   */
   public double getTotalSales() {
       return totalSales;
   }

   /**
   * @return the commisionRate
   */
   public double getCommisionRate() {
       return commisionRate;
   }

   /**
   * @param id
   * the id to set
   */
   public void setId(int id) {
       this.id = id;
   }

   /**
   * @param name
   * the name to set
   */
   public void setName(String name) {
       this.name = name;
   }

   /**
   * @param anualSalary
   * the anualSalary to set
   */
   public void setAnualSalary(double anualSalary) {
       this.anualSalary = anualSalary;
   }

   /**
   * @param totalSales
   * the totalSales to set
   */
   public void setTotalSales(double totalSales) {
       this.totalSales = totalSales;
   }

   /**
   * @param commisionRate
   * the commisionRate to set
   */
   public void setCommisionRate(double commisionRate) {
       this.commisionRate = commisionRate;
   }

   /**
   * method to calculate the total annual compensation
   *
   * @return
   */
   public double getTotalSalary() {

       return (getAnualSalary() + (getTotalSales() * getCommisionRate()));
   }

   /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString() {
       return "SalesPerson [id=" + id + ", name=" + name + ", anualSalary="
               + anualSalary + ", totalSales=" + totalSales
               + ", commisionRate=" + commisionRate
               + ", Total Annual Compensation=" + getTotalSalary() + "]";
   }

}

/**
* Name of the course:
* Name:
* Week number:
* Date:
*
*/

/**
* class to test the salesperson
*
* @author
*
*/
public class TestSalesPerson {

   /**
   * @param args
   */
   public static void main(String[] args) {

       SalesPerson person = new SalesPerson(2, "Srinivas", 24000, 50050, 4.2);
       System.out.println(person);
   }
}

OUTPUT:

SalesPerson [id=2, name=Srinivas, anualSalary=24000.0, totalSales=50050.0, commisionRate=4.2, Total Annual Compensation=234210.0]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote