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

A large company pays it salespeople on a commission basis. The salespeople recei

ID: 670662 • Letter: A

Question

A large company pays it salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $200 plus 9% of $5000, or a total of $650. You've been supplied with a list of the items sold by each sales person. The values are as follows:

Item         Value

1              239.99

2              129.75

3                99.95

4              350.89

Develop a Java application that inputs one salesperson's items sold for last week and calculates and displays that salesperson's earnings. There's no limit to the amount of items that can be sold.

Explanation / Answer

// java program that inputs one salesperson's items sold for last week and calculates and displays that salesperson's earnings. There's no limit to the amount of items that can be sold.

public class SalesCommissionCalculator //declare class to calculate the commision of sales person.

{

private String item;

private double value;

public SalesCommissionCalculator()

{

setItem("");

setValue(0.0);

}

public SalesCommissionCalculator(String i, double v)

{

setItem(i);

setValue(v);

}

public void setItem(String i)

{

item = i;

}

public void setValue(double v)

{

value = v;

}

public String getItem()

{

return item;

}

public double getValue()

{

return value;

}

public String toString()

{

return ("Item"+item+"Value"+value);

}

}

import javax.swing.JOptionPane;

import java.util.Scanner;

public class SalesCommissionCalculatorTest

{

public static void main(String args [])

{

int quantity;

int item;

double salary = 200.00;

double commission = 0.09;

double total= 0;

String msg="";

SalesCommissionCalculator item1 = new SalesCommissionCalculator("1", 239.99);

SalesCommissionCalculator item2 = new SalesCommissionCalculator("2", 129.75);

SalesCommissionCalculator item3 = new SalesCommissionCalculator("3", 99.95);

SalesCommissionCalculator item4 = new SalesCommissionCalculator("4", 350.89);

item=Integer.parseInt(JOptionPane.showInputDialog("Enter item number 1, 2, 3 or 4. Enter -1 to quit."));

while(item != -1)

{

switch(item)

{

case 1: quantity=Integer.parseInt(JOptionPane.showInputDialog("Enter quantity"));

total += (quantity*item1.getValue());

break;

case 2: quantity=Integer.parseInt(JOptionPane.showInputDialog("Enter quantity"));

total += (quantity*item1.getValue());

break;

case 3: quantity=Integer.parseInt(JOptionPane.showInputDialog("Enter quantity"));

total += (quantity*item1.getValue());

break;

case 4: quantity=Integer.parseInt(JOptionPane.showInputDialog("Enter quantity"));

total += (quantity*item1.getValue());

break;

default:

System.out.println("Invalid Item Number");

}

item=Integer.parseInt(JOptionPane.showInputDialog("Enter item number 1, 2, 3 or 4. Enter -1 to quit."));

}

msg = msg + String.format("Your Commission is $%.2f", (total*commission)+salary);

JOptionPane.showMessageDialog(null, msg);

}

}

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