Question

In: Computer Science

You work for a software company has just created a new incentive for salespeople to earn...

You work for a software company has just created a new incentive for salespeople to earn a commission on each sale. The current program only allows for a fixed salary. The Chief Information Officer (CIO) has asked you to create a new program that allows the functionality for a fixed salary and commission.

Write a Java® application, using NetBeans IDE, that calculates the total annual compensation of a salesperson.

Consider the following:

  • A salesperson will earn a fixed salary of $30,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 7% of total sales.
  • The total annual compensation is the fixed salary plus the commission earned.

The Java® application should meet the following 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).
  • A file needs to be created to contain the output.
  • 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.

Compile your Java® application files into a ZIP folder.

Solutions

Expert Solution

SalesCompensation.java

public class SalesCompensation {
  
// instance variables
private static double salary;
private double annualSales;
private static double commissionRate;
  
// overloaded constructor
public SalesCompensation(double annualSales)
{
commissionRate = 0.07;
this.salary = 30000;
this.annualSales = annualSales;
}

// getter method for the salary variable
public double getSalary() {
return salary;
}

// getter method for the annualSales variable
public double getAnnualSales() {
return annualSales;
}
  
// a method calculating and returning the commission earned
public double commissionEarned()
{
return(commissionRate * this.annualSales);
}
  
// a method calculating and returning the total annual compensation
public double totalAnnualCompensation()
{
return(this.salary + commissionEarned());
}
  
// a toString method to return the result in a proper format
@Override
public String toString()
{
return("Total Annual Sales: $" + String.format("%.2f", this.annualSales) + "\n"
+ "Salary: $" + String.format("%.2f", this.salary) + "\n"
+ "Commission Earned: $" + String.format("%.2f", commissionEarned()) + "\n"
+ "Total Annual Compensation: $" + String.format("%.2f", totalAnnualCompensation()));
}
}

SalesCompensationTester.java (Main/Driver class)

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class SalesCompensationTester {
  
// a static String variable for the filename
private static final String FILENAME = "sales_output.txt";
  
public static void main(String[] args)
{
// a Scanner object for user input
Scanner sc = new Scanner(System.in);
System.out.print("Enter the annual sales: $");
double annualSales = Double.parseDouble(sc.nextLine().trim());
  
// creating an instance of the SalesCompensation class
// by passing the annualSales as a parameter to the object constructor
SalesCompensation salesCompensation = new SalesCompensation(annualSales);
  
// displaying the result to the console
System.out.println("\nTOTAL EARNINGS:\n---------------\n" + salesCompensation.toString() + "\n");
  
// writing the above result to the .txt file
writeToFile(salesCompensation.toString());
}
  
// method to write the result to a .txt file
private static void writeToFile(String data)
{
FileWriter fw;
PrintWriter pw;
try {
fw = new FileWriter(new File(FILENAME));
pw = new PrintWriter(fw);
  
// writing the data to the file
pw.write(data);
System.out.println("Data has successfully been written to file: " + FILENAME + ".\n");
  
// releasing all resources after the task has been performed
pw.flush();
fw.close();
pw.close();
} catch (IOException ex) {
System.out.println("ERROR: " + ex.getMessage());
System.exit(1);
}
}
}

**************************************************************** SCREENSHOT ***********************************************************

CONSOLE OUTPUT :

OUTPUT FILE (sales_output.txt, file name may vary)


Related Solutions

You have just started up a new company in Nova Scotia. Your company produces software for...
You have just started up a new company in Nova Scotia. Your company produces software for the “Doctors Online” company which provides medical assessments and treatment recommendations via combination of online doctor appointments and extensive screening questionnaires. You need to invest $200,000 immediately to purchase computer equipment (CCA class number 45 with a CCA rate of 45% and no salvage value). If the anticipated operating costs (excluding your salary) are $15,000 per year increasing at 5% per year (inflation) and...
A software developer has created a new dating app that she thinks users will prefer over...
A software developer has created a new dating app that she thinks users will prefer over current options. She samples 260 millennials, and randomly splits them into 2 evenly-sized separate samples: the New Dating App Group and the Tinder Group. The dependent variable is self-reported satisfaction of the app on a 1-10 scale. Choose the best statistical test for this research design. A. Repeated Measures ANOVA B. Correlation C. Independent measures t-test D. Regression
Choice 1. You are the new software developer at work. You are brought into a meeting...
Choice 1. You are the new software developer at work. You are brought into a meeting with clients that do not understand the idea of sorting data. Now you know, that you cannot use complex math to explain, but you can illustrate in diagrams. Basically, this group has been working with unsorted data and you must explain why their searches and reports will be so much faster with sorted data. You do not know anything specific about their data, but...
I work for a software company. We use several metrics to evaluate new software projects, including...
I work for a software company. We use several metrics to evaluate new software projects, including increased sales, retention, and revenue. One quality we look for is innovation. This often prompts a discussion of "how do you measure innovation." How do you say that one idea is more or less innovative than another? We often turn to our competitors and say if they aren't doing it then the idea is innovative... but that may also be a sign that the...
Suppose an employer has a pressing need to attract new engineers. As an incentive, the company...
Suppose an employer has a pressing need to attract new engineers. As an incentive, the company increases its amount of life insurance for its engineers from $80,000 to $120,000, while coverage for all other company positions remains the same. This company's life insurance benefits are most likely based on a/an _______ schedule. A. position B. flat-benefit C. earnings D. combination of benefits
You are the Director of Global Compliance for a U.S. company that just created a revolutionary...
You are the Director of Global Compliance for a U.S. company that just created a revolutionary new portable personal computer (PPC) that is half the size of a laptop, performs the same functions as existing laptop computers but costs only half as much to manufacture. Several patents were filed and approved protect the unique design of this computer. Your CEO asked you to formulate a recommendation for how to expand into South America.Evaluate the pros and cons if you were...
You are the Director of Global Compliance for a U.S. company that just created a revolutionary...
You are the Director of Global Compliance for a U.S. company that just created a revolutionary new portable personal computer (PPC) that is half the size of a laptop, performs the same functions as existing laptop computers but costs only half as much to manufacture. Several patents were filed and approved protect the unique design of this computer. Your CEO asked you to formulate a recommendation for how to expand into South America. Evaluate the pros and cons if you...
You are the Director of Global Compliance for a U.S. company that just created a revolutionary...
You are the Director of Global Compliance for a U.S. company that just created a revolutionary new portable personal computer (PPC) that is half the size of a laptop, performs the same functions as existing laptop computers but costs only half as much to manufacture. Several patents were filed and approved protect the unique design of this computer. Your CEO asked you to formulate a recommendation for how to expand into South America. Evaluate the pros and cons if you...
Mary and George both work for a software development company. The manager of the new product...
Mary and George both work for a software development company. The manager of the new product division was originally the leader of the project team for which she interviewed and hired George. Mary, another project team member, also interviewed George but strongly opposed hiring him for the project because she thought he was not competent to do the job. Seven months after George was hired, the manager left the project to start her own company and recommended that George and...
Andrew, a highly qualified and experienced software developer, has just started work with a government health...
Andrew, a highly qualified and experienced software developer, has just started work with a government health department on a project that has been underway for about 9 months. He is replacing a novice developer who has decided to move on to a new project with another organisation. Even though the current system is incomplete, it has is being used with 'live' data. On analysing what's been done so far, Andrew discovers that the system is poorly designed and is riddled...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT