A Large company pays its salespeople on a commission basis. The salespeople rece
ID: 3754785 • Letter: A
Question
A Large company pays its salespeople on a commission basis. The salespeople receive $500 per week plus 8% of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $500 plus 8% of $5000, or total earnings of $900. Develop a Java application that inputs the salesperson’s name and total gross sales for that week, calculates and displays that salesperson’s total earnings. There is no limit to the number of items sold. After the loop has finished, print out the total earnings for all salespersons. Use the sentinel control algorithm shown in class and the textbook if you want a passing grade on this lab assignment.
Explanation / Answer
Below is your code. Let me know if there is any issues: -
public class SalesPerson {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name;
Double sales = 0.0, earning = 0.0, partialEarning = 0.0;
System.out.print("Enter SalesPerson's Name : ");
name = sc.next();
while (sales != -1.0) {
System.out.print("Enter sales in dollars (-1 to end) : ");
sales = sc.nextDouble();
if (sales != -1.0) {
partialEarning = 500 + (0.08 * sales);
System.out.println("Salary : " + partialEarning);
earning = earning + partialEarning;
}
System.out.println();
}
System.out.println(name + " earned total of $" + earning);
sc.close();
}
}
Output
Enter SalesPerson's Name : Rakesh
Enter sales in dollars (-1 to end) : 5000
Salary : 900.0
Enter sales in dollars (-1 to end) : 2500
Salary : 700.0
Enter sales in dollars (-1 to end) : 15340
Salary : 1727.2
Enter sales in dollars (-1 to end) : 3900
Salary : 812.0
Enter sales in dollars (-1 to end) : -1
Rakesh earned total of $4139.2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.