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

Problem Statement: A real estate company needs a program written to compute comm

ID: 3605203 • Letter: P

Question

Problem Statement: A real estate company needs a program written to compute commissions for their agents. The program will be run each Friday for an unknown number of sales that closed that week. An agent will receive a separate check for each sale that closed during the week. The company has 3 categories of properties. Each property category carries with it a different description and commission rate as can be seen in the table below. Description of Property Commission Rate Category “R" or "r" "D" or "d" “C" or "c” Residential Multiunit Dwelling Commercial 5% 10% 15% Write a program that: .asks the user for the agent ID (a 5-digit numeric identification number), the category of property that was sold ("R", "r, "D”, “d", "C" or "c") and the selling price of the property computes and prints the commission for that sale belonging to that agent. keeps a running total of the number of commissions computed for each property category. keeps a running total of the commissions for each property category Outputs the running totals at the end of run as shown on the back of this page.

Explanation / Answer

Java code for the given case.I have written this code using Eclipse IDE. Kindly use Cntrl+F11

Below is the java code:

import java.util.*;

public class CommissionRateCalculator

{

public static void main(String[]args)

{

//Scanner class to read inputs from keyboard(user)

Scanner in=new Scanner(System.in);

//variable declaration

int resCounter=0;int dwellCounter=0;int comCounter=0;

float resCommission=0.0f;float dwellCommission=0.0f;float comCommission=0.0f;

System.out.println("**************Your Name Commission Computer************");

//while loop

while(true)

{

System.out.println(" Do you have a commission to computer?(1=yes,0=no)");

int com=in.nextInt();

//if commision==1 the if condition

if(com==1)

{

//asking user to inputs

System.out.println("Please enter the Agent ID:");

int agentId=in.nextInt();

System.out.println("Please enter the category of property sold:");

System.out.println("(R=residential,C=commericial,D=multi/dwell):");

in.nextLine();

char property=in.nextLine().charAt(0);

System.out.println("Please enter the selling price:");

float sellingPrice=in.nextFloat();

//using of switch structure

switch(property)

{

//case if R

case 'R': resCounter++;

resCommission=resCommission+(float)0.05*sellingPrice;

System.out.println("Commission for this sale for Agent "+agentId+" is "+resCommission);

break;

case 'r': resCounter++;

resCommission=resCommission+(float)0.05*sellingPrice;

System.out.println("Commission for this sale for Agent "+agentId+" is "+resCommission);

break;

//case if D

case 'D':

dwellCounter++;

dwellCommission=dwellCommission+(float)(0.10)*sellingPrice;

System.out.println("Commission for this sale for Agent "+agentId+" is "+dwellCommission);

break;

case 'd': dwellCounter++;

dwellCommission=dwellCommission+(float)(0.10)*sellingPrice;

System.out.println("Commission for this sale for Agent "+agentId+" is "+dwellCommission);

break;

//case if C

case 'C': comCounter++;

comCommission=comCommission+(float)(0.15)*sellingPrice;

System.out.println("Commission for this sale for Agent "+agentId+" is "+comCommission);

break;

case 'c': comCounter++;

comCommission=comCommission+(float)(0.15)*sellingPrice;

System.out.println("Commission for this sale for Agent "+agentId+" is "+comCommission);

break;

}

}else

{

//displaying output

System.out.println("************End of Run Report**********");

System.out.println("Total number of Residential commissions computed= "+resCounter);

System.out.println("Total number of Commericial commissions computed= "+comCounter);

System.out.println("Total number of Multi/Dwell commissions computed= "+dwellCounter);

System.out.println("Total number of all commissions computed= "+(resCounter+comCounter+dwellCounter));

System.out.println("Total amount of Residential commissions computed= "+resCommission);

System.out.println("Total amount of Commericial commissions computed= "+comCommission);

System.out.println("Total amount of Multi/Dwell commissions computed= "+dwellCommission);

System.out.println("Total amount of all commissions computed= "+(resCommission+comCommission+dwellCommission));

System.exit(0);

}

}

}

}

Output:

**************Your Name Commission Computer************

Do you have a commission to computer?(1=yes,0=no)

1

Please enter the Agent ID:

11111

Please enter the category of property sold:

(R=residential,C=commericial,D=multi/dwell):

R

Please enter the selling price:

350000

Commission for this sale for Agent 11111 is 17500.0

Do you have a commission to computer?(1=yes,0=no)

1

Please enter the Agent ID:

22222

Please enter the category of property sold:

(R=residential,C=commericial,D=multi/dwell):

d

Please enter the selling price:

500000

Commission for this sale for Agent 22222 is 50000.0

Do you have a commission to computer?(1=yes,0=no)

1

Please enter the Agent ID:

33333

Please enter the category of property sold:

(R=residential,C=commericial,D=multi/dwell):

C

Please enter the selling price:

800000

Commission for this sale for Agent 33333 is 120000.01

Do you have a commission to computer?(1=yes,0=no)

1

Please enter the Agent ID:

33333

Please enter the category of property sold:

(R=residential,C=commericial,D=multi/dwell):

d

Please enter the selling price:

1000000

Commission for this sale for Agent 33333 is 150000.0

Do you have a commission to computer?(1=yes,0=no)

0

************End of Run Report**********

Total number of Residential commissions computed= 1

Total number of Commericial commissions computed= 1

Total number of Multi/Dwell commissions computed= 2

Total number of all commissions computed= 4

Total amount of Residential commissions computed= 17500.0

Total amount of Commericial commissions computed= 120000.01

Total amount of Multi/Dwell commissions computed= 150000.0

Total amount of all commissions computed= 287500.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