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

Develop a Java program that will read a file of sales volume and print a report

ID: 3891161 • Letter: D

Question

Develop a Java program that will read a file of sales volume and print a report with the sales commission of each salesperson. Each input record should contain salesperson number, name and that person’s volume of sales for the month. The crate of commission is based on the following table:

On sales volume ($) of             Commission rate (%)

$0.00–$200.00                      5
$200.01–$1000.00                 8
$1000.01–$2000.00            10
$2000.01 and above             12

The calculated commission is an accumulated amount according to the sales volume figure.

For example, the commission owing for a sales volume of $1200.00 would be calculated as follows: Commission = (200 * 5%) + ((1000 – 200) * 8%) + ((1200 – 1000) * 10%))

The program should print the salesperson number, name, volume of sales and calculated commission, with the appropriate column headings. Here are the parts of this question. - Identify at least 3 methods that will be used.
- One of the methods will calculate the sales commission.
-Assemble a working program with methods stubs. Each method should have a javadoc comment block and a method body that only returns an appropriate value.
- Complete the stubs and develop a fully working and documented java program.

Here is pseudocode that should help with calculating commission:
Calculate sales commission

If sales volume < 200 then?
Commission = Sales volume * 0.05?
Else
If sales volume < 1000 then?
Commission = (200 * 0.05) + ((sales volume – 200) * 0.08?
Else If
sales volume < 2000 then?
commission = (200* 0.05) + (800 * 0.08) + ? ((Sales volume – 1000) * 0.1)
Else?
Commission = (200 * 0.05) + (800 * 0.08) + (1000 * 0.1) + ((sales_volume – 2000) * 0.12)?
End if

Explanation / Answer

Program


package salescommission;
import java.io.File;
import java.util.Scanner;

public class Salescommission
{

    public static void main(String[] args)throws Exception

    {
        Salescommission g=new Salescommission ();
        File file =new File("salesreport.txt");
    Scanner src = new Scanner(file);
    int i,j=0;
    double d;

    String str;
    int salesnumber[]=new int[100];
    double salesamount[]=new double[100];
    String salesman[]=new String[100];
    while (src.hasNext())
    {
    
        i = src.nextInt();
        salesnumber[j]=i;
     
        str = src.next();
        salesman[j]=str;
       
        d = src.nextDouble();
        salesamount[j]=d;
    
        j++;
    }
    g.calculateCommission(salesnumber,salesman,salesamount,j);
  
    }
    public void calculateCommission(int[] salesnumber,String[] salesman,double[] salesamount,int j)
    {
        //Calculate commission
        int i;
        double Commission[]=new double[100];
    System.out.println("ID Name Volume Commission");
for(i=0;i<j;i++)
{
if (salesamount[i]< 200)
Commission[i] = salesamount[i] * 0.05;
else if (salesamount[i]< 1000)
Commission[i]=(200 * 0.05)+.08*(salesamount[i]-200);
else if (salesamount[i]< 2000)
Commission[i] = (200 * 0.05)+(800 * 0.08)+ ((salesamount[i]-1000) * 0.1);
else
Commission[i] = (200 * 0.05) + (800 * 0.08) + (1000 * 0.1) + ((salesamount[i]-2000) * 0.12);



}
printReport(salesnumber,salesman,salesamount,Commission,j);
}
    public void printReport(int[] salesnumber,String[] salesman,double[] salesamount,double[] Commission,int j)
    {
        //Print sales report
        for(int i=0;i<j;i++)
{
        System.out.println(salesnumber[i]+" "+salesman[i]+" "+salesamount[i]+" "+Commission[i]);
    }
    }
}

Output


ID Name Volume Commission
100 Tim 200.0 10.0
101 David 250.0 14.0
102 Peter 550.0 38.0
103 Nancy 1400.0 114.0
104 John 1800.0 154.0
105 Xavier 1250.0 99.0

Input File

100 Tim 200.00
101 David 250.00
102 Peter 550.00
103 Nancy 1400.00
104 John 1800.00
105 Xavier 1250.00

Dr Jack
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote