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

Urgent help needed!! Thank you (Object-Orientated) Java Programming Write a prog

ID: 3596113 • Letter: U

Question

Urgent help needed!! Thank you (Object-Orientated) Java Programming

Write a program to produce a sales commission report from a company’s sales file (sales.txt). Each record on the sales file contains the salesperson’s number, name and sales amount.

Your program is to read the sales file, calculate the sales commission according to the following table, and print a sales commission report.

Sales range

Commission rate

$0–$499.99

No commission

$500.00–$749.99

2%

$750.00 and above

3%

Each detail line is to contain the salesperson’s number, sales amount, commission rate and total commission. Print headings and column headings at the top of each page, allowing for 8 records per page, and at the end of the report, the total commission, as follows:

SALES COMMISSIONS                                                  PAGE: XX

SALESPERSON         SALESPERSON SALES AMOUNT       COMMISSION COMMISSION

NAME                NUMBER                           RATE

xxxxx               xxxxxxxxxxx       9999.99        x%               999.99

xxxxx               xxxxxxxxxxx       9999.99        x%               999.99      

TOTAL COMMISSION 9999.99

Use divide and conquer concept to split the program code into a set of customised methods such as printPageHeading, processSaleRecord, printLineItem(), printReportFooter and etc.

Sales range

Commission rate

$0–$499.99

No commission

$500.00–$749.99

2%

$750.00 and above

3%

Explanation / Answer

The output is not shown properly here because of the Chegg editor. Kindly run the code in the IDE to get proper results.

The input file has been provided. sales.txt

methods such as printPageHeading, processSaleRecord, printLineItem(),printReportFooter are defined and declared,

I hope this helps. Kindly rate the answer if this helps you, All the best. :)

*****************************************************************************************************************************

Code:

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

public class Sales {

public static void main(String[] args) {

try {

File file = new File("sales.txt");

FileReader fileReader = new FileReader(file);

BufferedReader bufferedReader = new BufferedReader(fileReader);

String stringBuffer;

String line;

int page =1;

int records=0;

printPageHeading(1);

double total=0;

while ((line = bufferedReader.readLine()) != null) {

String arr[]=line.split(" ");

double commission = processSaleRecord(Integer.parseInt(arr[2]));

total+=commission;

printLineItem(arr[1],arr[0],arr[2],rate(Integer.parseInt(arr[2])),commission);

records++;

if(records==8)

{

page++;

printPageHeading(page);

records=0;

}

}

printReportFooter(total);

fileReader.close();

} catch (IOException e) {

e.printStackTrace();

}

}

private static void printLineItem(String string, String string2, String string3, int rate, double commission) {

// TODO Auto-generated method stub

System.out.println(string+" "+string2+" "+string3+" "+rate+"% "+commission);

}

private static double processSaleRecord(int amount) {

// TODO Auto-generated method stub

if(amount> 0 && amount<=499.99)

return 0;

else if(amount > 500.00 && amount <= 749.99)

return 0.02*amount;

else if(amount >= 750.00)

return 0.03*amount;

return 0;

}

private static int rate(int amount) {

// TODO Auto-generated method stub

if(amount> 0 && amount<=499.99)

return 0;

else if(amount > 500.00 && amount <= 749.99)

return 2;

else if(amount >= 750.00)

return 3;

return 0;

}

public static void printPageHeading(int page) {

System.out.println(" SALES COMMISSIONS PAGE:"+page);

System.out.println("SALESPERSON NAME SALESPERSON NUMBER SALES AMOUNT COMMISSION RATE COMMISSION ");

}

public static void printReportFooter(double total) {

System.out.println(" TOTAL COMMISSION "+total);

}

}

*********************************************************************************************************************************

sales.txt

12345 ABC 2000
12346 ABCD 3000
12347 ABCX 100
12348 ABCC 1000
12349 ABCV 21000
12340 ABCB 22000
12342 ABCN 200
12341 ABCM 2400
12343 ABCR 400
12345 ABC 2000
12346 ABCD 3000
12347 ABCX 100
12348 ABCC 1000
12349 ABCV 21000
12340 ABCB 22000
12342 ABCN 200
12341 ABCM 2400
12343 ABCR 400
12345 ABC 2000
12346 ABCD 3000
12347 ABCX 100
12348 ABCC 1000
12349 ABCV 21000
12340 ABCB 22000
12342 ABCN 200
12341 ABCM 2400
12343 ABCR 400

****************************************************************************************************************

Output:

SALES COMMISSIONS PAGE:1

SALESPERSON NAME SALESPERSON NUMBER SALES AMOUNT COMMISSION RATE COMMISSION

ABC 12345 2000 3% 60.0

ABCD 12346 3000 3% 90.0

ABCX 12347 100 0% 0.0

ABCC 12348 1000 3% 30.0

ABCV 12349 21000 3% 630.0

ABCB 12340 22000 3% 660.0

ABCN 12342 200 0% 0.0

ABCM 12341 2400 3% 72.0

SALES COMMISSIONS PAGE:2

SALESPERSON NAME SALESPERSON NUMBER SALES AMOUNT COMMISSION RATE COMMISSION

ABCR 12343 400 0% 0.0

ABC 12345 2000 3% 60.0

ABCD 12346 3000 3% 90.0

ABCX 12347 100 0% 0.0

ABCC 12348 1000 3% 30.0

ABCV 12349 21000 3% 630.0

ABCB 12340 22000 3% 660.0

ABCN 12342 200 0% 0.0

SALES COMMISSIONS PAGE:3

SALESPERSON NAME SALESPERSON NUMBER SALES AMOUNT COMMISSION RATE COMMISSION

ABCM 12341 2400 3% 72.0

ABCR 12343 400 0% 0.0

ABC 12345 2000 3% 60.0

ABCD 12346 3000 3% 90.0

ABCX 12347 100 0% 0.0

ABCC 12348 1000 3% 30.0

ABCV 12349 21000 3% 630.0

ABCB 12340 22000 3% 660.0

SALES COMMISSIONS PAGE:4

SALESPERSON NAME SALESPERSON NUMBER SALES AMOUNT COMMISSION RATE COMMISSION

ABCN 12342 200 0% 0.0

ABCM 12341 2400 3% 72.0

ABCR 12343 400 0% 0.0

TOTAL COMMISSION 4626.0

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