Modify The Week Two Java Application Using NetBeans IDE To M
Modifythe Week Two Java Application Using Netbeans Ide To Meet These A
Modify the Week Two Java application using NetBeans IDE to meet these additional and changed business requirements: The company has recently changed its total annual compensation policy to improve sales. A salesperson will continue to earn a fixed salary of $100,000. The current sales target for every salesperson is $120,000. The sales incentive will only start when 80% of the sales target is met. The current commission is 5% of total sales. If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is 1.25. The application should ask the user to enter annual sales and should display the total annual compensation. The application should also display a table of potential total annual compensation that the salesperson could have earned, in $5000 increments above the salesperson's annual sales, until it reaches 50% above the salesperson's annual sales. Sample Table: Assuming a total annual sales of $100,000, the table would look like this: Total Sales Total Compensation 100,000 105,000 110,000 115,000 120,000 125,000 130,000 135,000 140,000 145,000 150,000 . The Java application should also meet these technical requirements: The application should have at least one class, in addition to the application's controlling class. The source code must demonstrate the use of conditional and looping structures. There should be proper documentation in the source code.
Paper For Above instruction
Introduction
The development of a Java application to accurately calculate and display a salesperson’s annual compensation based on evolving business policies requires a thoughtful approach, integrating user input, conditional logic, and looping structures. With recent changes to the company's compensation strategy—namely, the introduction of a sales acceleration factor and a dynamic table showcasing potential earnings—the application must be sufficiently flexible and informative. In this context, the program must accept user input for annual sales, compute total compensation, and generate a comprehensive table illustrating possible earnings across a range of sales figures. This paper outlines the process of designing and implementing such an application in Java, emphasizing key programming concepts, class structure, and adherence to technical specifications.
Design Objectives
- Utilize at least one class besides the main driver class to demonstrate object-oriented principles.
- Implement conditional statements to evaluate sales thresholds and calculate commissions accordingly.
- Employ looping structures to generate a sequence of potential sales and corresponding compensation figures.
- Provide clear documentation within source code for maintainability and clarity.
Application Logic and Calculations
The core logic revolves around determining total annual compensation based on user-entered sales. The fixed salary is set at $100,000. The sales target is $120,000, and incentives are activated only if sales exceed 80% of this target (i.e., $96,000). Sales below this threshold yield no commission. Beyond this threshold, a 5% commission applies, with an acceleration factor boosting commission earnings for sales exceeding the target. Specifically:
- If sales
- If sales ≥ 80% but ≤ target, total compensation = fixed salary + 5% of sales.
- If sales > target, total compensation = fixed salary + (commission + acceleration bonus)
The acceleration bonus increases the commission based on how much sales exceed the target, scaled by the acceleration factor of 1.25. The table generated will increment sales by $5,000 starting from the entered sales amount, up to 50% above that amount.
Implementation Details
Class Structure
The application consists of at least two classes:
- SalesPerson: Encapsulates properties and methods related to sales, including calculation of commissions and total compensation.
- SalesApp: Contains the main() method, handles user interaction, and displays results.
Code Highlights
- Conditional statements (if-else) to evaluate sales thresholds for commission calculation.
- Looping (for loop) to generate sales ranges and corresponding compensation display.
- Input validation to ensure user enters a numeric value.
- In-line documentation and comments for clarity.
Sample Implementation
The following Java code demonstrates the described logic, class structure, and features, adhering to the technical and functional requirements.
SalesPerson.java
public class SalesPerson {
// Constants
private static final double FIXED_SALARY = 100000.0;
private static final double SALES_TARGET = 120000.0;
private static final double BONUS_THRESHOLD_PERCENT = 0.8; // 80%
private static final double COMMISSION_RATE = 0.05; // 5%
private static final double ACCELERATION_FACTOR = 1.25;
private double annualSales;
public SalesPerson(double sales) {
this.annualSales = sales;
}
/**
* Calculates total compensation based on sales.
* @return total compensation amount.
*/
public double calculateTotalCompensation() {
double totalCompensation = FIXED_SALARY;
if (annualSales
// Sales below 80% of target: no commission
return totalCompensation;
} else if (annualSales
// Between threshold and target: standard commission
totalCompensation += annualSales * COMMISSION_RATE;
} else {
// Sales above target
double excessSales = annualSales - SALES_TARGET;
double commission = SALES_TARGET COMMISSION_RATE + excessSales COMMISSION_RATE * ACCELERATION_FACTOR;
totalCompensation += commission;
}
return totalCompensation;
}
}
SalesApp.java
import java.util.Scanner;
public class SalesApp {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double userSales = 0.0;
// Prompt user for annual sales input with validation
System.out.print("Enter the salesperson's annual sales (in dollars): ");
while (true) {
if (scanner.hasNextDouble()) {
userSales = scanner.nextDouble();
if (userSales >= 0) {
break;
} else {
System.out.print("Please enter a non-negative number: ");
}
} else {
System.out.print("Invalid input. Please enter a numeric value: ");
scanner.next();
}
}
SalesPerson sp = new SalesPerson(userSales);
double totalCompensation = sp.calculateTotalCompensation();
// Display total compensation for the entered sales
System.out.printf("Total annual compensation for sales of $%.2f is: $%.2f%n", userSales, totalCompensation);
// Generate and display the table for sales increments
System.out.println("\nPotential Total Compensation Table:");
System.out.printf("%-15s %-20s%n", "Total Sales", "Total Compensation");
double startSales = userSales;
double endSales = userSales + (userSales * 0.5); // 50% above sales
double increment = 5000.0;
for (double sales = startSales; sales
SalesPerson spIncrement = new SalesPerson(sales);
double comp = spIncrement.calculateTotalCompensation();
System.out.printf("$%-14.2f $%-19.2f%n", sales, comp);
}
scanner.close();
}
}
Conclusion
This Java application effectively models a salesperson’s compensation structure based on updated business rules, including thresholds, commissions, and acceleration factors. The use of object-oriented principles, conditional logic, and looping constructs ensures a modular, flexible, and comprehensive program. By allowing input and generating a detailed compensation table across a range of sales figures, the application provides valuable insights and aligns with business analysis needs. Proper code documentation aids future maintenance and understanding, fulfilling the technical specifications.
References
- Gaddis, T. (2018). Starting Out with Java: From Control Structures through Objects. Pearson.
- Holzner, S. (2019). Programming Java: A Guide for Java Programmers. Jones & Bartlett Learning.
- Deitel, P., & Deitel, H. (2017). Java How to Program. Pearson.
- Baeldung. (2022). Java Conditional Statements. Retrieved from https://www.baeldung.com/java/conditional-statements
- Oracle. (2023). Java SE Documentation. Oracle.
- Core Java Volume I & II. (2018). Cay S. Horstmann. Pearson.
- Javarevisited. (2020). Looping Constructs in Java. Retrieved from https://javarevisited.blogspot.com
- Java Programming Tutorials. (2022). Loop and Conditional Structures. TutorialsPoint.
- Effective Java. (2017). Joshua Bloch. Addison-Wesley.