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

Problem: Write a program to prepare a monthly report for a legal clinic. Input c

ID: 3729884 • Letter: P

Question

Problem: Write a program to prepare a monthly report for a legal clinic. Input consists of a name of the client, name of the attorney, the hours worked by the attorney on the case.   The fee charged by the attorney is based on the hours worked. Every attorney has a min number of hours with a specific rate, after the min number of hours there is a percent discount given by the attorney.

Note: A shell has been provided to you. You can deviate from the shell as long as you use methods and you have the exact same output.


The Shell is provided below

/***************************

* YOUR HEADER HERE

***************************/

import java.util.*;

public class ReportShell

{

public static void main(String[] args)

{

Scanner kb = new Scanner(System.in);

process(kb);

//System.out.println(s);

}

/*This method asks the user for the number of the clients*/

public static void process(Scanner kb)

{

//call the method description

//ask the user for the number of clients

//declare variables for total hours and total income

//use the format method from the string class to create a string

called title for the title of the items in the report

//declare a string variable to hold the report and initialize it title

// for(int i = 1; i <= clients; i++)

{

//get the name of the client

//get the name of the lawyer

//get the number of the hours spent on the case and store it in

the variable hours

//get the minimum hours

//get the fee for the minimum hours

//get the percentage for the discount

//call the method getFee to get the total cost for the client and

store it in a variable called fee

//call the method getDiscountedHours

//calculate the regular hours

//add hours to total hours

//add the fee to the total income

//use the format method from the string class to cretae a formated

string called s containing all the info about the client

//add s to the report variable

}

//output the report

//output totalhours and total income

}

/*this method creates the description of what this program does*/

public static void description()

{

}

/*This method creates the star lines */

public static void frame()

{

The output is given below:

This program generates a summary report for the Best Law Firm Clients are charged based on the number of hours. Depending on the assigned lawyer, clients get an hourly discount after certain number of hours The provided discount is offered by each individual lawyer and it could vary from one lawyer to another How many clients do you have: 3 Enter the name of the client: Mary Enter the name of the lawyer: Alex Enter the hours: 45 Enter the base hours: 13 Enter the fee for the first 13.0 hours: 350 Enter the discount percentage: (5, 10, 20, 25,...): 5 Enter the name of the client: Joe Enter the name of the lawyer: Jake Enter the hours: 67 Enter the base hours: 34 Enter the fee for the first 34.0hours: 200 Enter the discount percentage: (5, 10, 20, 25,...): 3 Enter the name of the client: Nancy Enter the name of the lawyer: Martin Enter the hours: 77 Enter the base hours: 85 Enter the fee for the tirst 85.0 hours: 250 Enter the discount percentage: (5, 10, 20, 25,...): 2 The report is ready, Hit enter key to view it. Client Lawyer Hours Fee %Discount Reg Hours Discounted Hours Total Fee Mary Ale45. 350.00 Joe Jake 67.00 200.00 Nancy Martin 77.00 250.00 5.00 3.00 2.00 13.00 34.00 77.00 32.00 33.00 0.00 15190.00 13202.00 19250.00 Total Hours 189.00 Total Incone 47642.00

Explanation / Answer

package test.com;

import java.util.*;

public class ReportShell

{

public static void main(String[] args)

{

Scanner kb = new Scanner(System.in);

process(kb);

//System.out.println(s);

}

/*This method asks the user for the number of the clients and generate the report too*/

public static void process(Scanner kb)

{

description();//call the method description

System.out.println("How many clients do you have :");

int noOfclients = kb.nextInt();

int totalHours=0;

double income=0.0;

Formatter formatter = new Formatter();

formatter.format("%20s %20s %20s %20s %20s %20s %20s %20s","Client", "Lawyer", "Hours", "Fee", "%Discount", "Reg Hours", "Discounted Hours", "Total Fee");

StringBuilder rep = new StringBuilder();

rep.append(formatter);

rep.append(System.getProperty("line.separator"));

for(int i = 1; i <= noOfclients; i++)

{

System.out.println("Enter the name of the client :"+ kb.nextLine());

String clientName= kb.nextLine();

System.out.println("Enter the name of the lawyer :");

String lawyerName = kb.nextLine();

System.out.println("Enter the hours :");

int hours = kb.nextInt();

System.out.println("Enter the base hours :");

int baseHours = kb.nextInt();

System.out.println("Enter the fee for the first "+baseHours+" hours :");

float feePerHour = kb.nextFloat();

System.out.println("Enter the discount percentage:{5,10,20,25,....}: ");

int discountedPercentage = kb.nextInt();

System.out.println("==============================================================================");

//call the method getFee to get the total cost for the client and

//store it in a variable called fee

float TotalFee = getFee(discountedPercentage,baseHours,hours,feePerHour);

//call the method getDiscountedHours

int discountedHrs = getDiscountedHour(hours, baseHours);

//calculate the regular hours

int regularHrs = baseHours;

//add hours to total hours

totalHours = totalHours+hours;

//add the fee to the total income

income = income+TotalFee;

//use the format method from the string class to cretae a formated

Formatter formatter1 = new Formatter();

formatter1.format("%20s %20s %20s %20f %20s %20s %20s %20f",clientName, lawyerName, hours, feePerHour, discountedPercentage, regularHrs, discountedHrs, TotalFee);

//string called s containing all the info about the client

rep.append(System.getProperty("line.separator"));

rep.append(formatter1);

//add s to the report variable

}

System.out.println("The report is ready,Hit Enter to view it "+kb.nextLine());

System.out.println(rep);

System.out.println("Total Hours Total Income ");

System.out.println(totalHours+" "+income);

}

/*this method creates the description of what this program does*/

public static void description()

{

System.out.println("*************************************************************************************************************");

System.out.println("This program generates a summary report for the Best Law Firm Clients are charged based on the number of hours. "

+ "Depending on the assigned lawyer, clients get an hourly discount after certain number of hours. "

+ "The provided discount is offered by each individual lawyer and it could vary from one lawyer to another");

System.out.println("*************************************************************************************************************");

}

/*This method calculate the fee */

public static float getFee(int dp, int bh,int th,float fph)

{ float totalCost;

float cost4bh = bh*fph;

int dh = getDiscountedHour(th,bh);

float cost4dhBeforeDiscount=dh*fph;

float discount = dh*fph*dp/100;

float cost4dhAfterDiscount= cost4dhBeforeDiscount-discount;

if(th>bh) {

totalCost = cost4bh+cost4dhAfterDiscount;

}else{

totalCost = cost4bh;

}

return totalCost;

}

/*

* This method is used to get the discounted hours

*/

public static int getDiscountedHour(int th,int bh) {

return (th-bh);

}

}

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