In java Note: A shell has been provided to you. You can deviate from the shell a
ID: 3729413 • Letter: I
Question
In java 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 http://www.heypasteit.com/clip/0IJEML 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: you need to understand the problem before writing your code. Examine the provide output to find out the details. Refer to the sample output file provided below to you for more details. Please include these in your program: 1. Use of methods 2. Proper comments 3. Proper indentation 4. Exact same output as the provided one 5.. No hard coding throughout the program. s output F Edt Format View Help This program generates a summary report for the Best Lav Firm Clients are charged based on the number of hours. Depending on the assigned lawyer, clients get an hourly dis clients get an hourly discount after certain number of hours. ided discount is offered by each individual lawyer and it could vary from one lauyer to another How sany cllents do you have : 3 Enter the nase of the client:Mary Enter the nase of the lawyer: Alex Enter the hours34 Enter the base hours: 25 Enter the fee for the first 2s8.0 hours:100 Enter the discount percentage: (5, 1, 20, 25,..) 1e Enter the name of the client: Patel Enter the nase of the lawyer: Jason Enter the hours : 66 Enter the base hours: 20 Enter the fee for the first 28.8 hours: 38e Enter the discount percentage: (S, 1e, 2e, 25,...) 28 Enter the nase of the cllent: Joe Enter the nase of the lavyer: Jack Enter the hours :89 Enter the base hours: 45 Enter the fee for the first 45.8 hours:480 er the discount percentage: (S, 1e, 2e, 2)4 The report is ready, Hit enter key to view it. Client Laeyer Hours FeeDiscount Reg Hours Discounted Hours Total Fee Hary Alex 34.80 100.00 Patel Jason 66.00 38e.89 Joe Jack 89.80 480.00 10.00 20.00 4.00 4.00 0.00 45.00 3480.00 17040.00 4896.00 0.00 44.00 Total Hours 189.00 Total Income 55336.0Explanation / Answer
/**The java program that prompts number of clients and then
* collect the data from user and print the total hours
* and total income on console.*/
//Discount.java
import java.util.Scanner;
public class Discount {
public static void main(String[] args) {
Scanner kb=new Scanner(System.in);
System.out.println("This program generates a summary report for the Best Law Firm");
System.out.println("Clients are charged based on the number of hours.");
System.out.println("Depending on the assigned lawyer, clients get an hourly discount after certain number of hours.");
System.out.println("The provided discount is offered by each individual lawyer and it could vary from one lawyer to another");
System.out.printf("------------------------------------------");
System.out.printf("------------------------------------------ ");
int num_clients;
System.out.printf("How many clients do you have :");
//prompt for number of clients
num_clients=Integer.parseInt(kb.nextLine());
//declare arrays of size number of clients
String[] client=new String[num_clients];
String[] lawyer=new String[num_clients];
double[] hours=new double[num_clients];
double[] basehours=new double[num_clients];
double[] fee=new double[num_clients];
double[] disc=new double[num_clients];
//read client data
for (int i = 0; i < num_clients; i++) {
System.out.printf("Enter the name of the client :");
client[i]=kb.nextLine();
System.out.printf("Enter the name of the lawyer :");
lawyer[i]=kb.nextLine();
System.out.printf("Enter the hours :");
hours[i]=Double.parseDouble(kb.nextLine());
System.out.printf("Enter the base hours :");
basehours[i]=Double.parseDouble(kb.nextLine());
System.out.printf("Enter the fee for the first %5.2f hours :",basehours[i]);
fee[i]=Double.parseDouble(kb.nextLine());
System.out.printf("Enter the discount percentage:(5,10,20,25,...)");
disc[i]=Double.parseDouble(kb.nextLine());
System.out.printf("------------------------------------------");
System.out.printf("------------------------------------------ ");
}
double discount_hours=0;
double discount_amount=0;
double regular_hours=0;
double net_amount=0;
double total_hours=0;
double total_income=0;
System.out.printf("%-10s%-10s%-10sf%-10s%-10s%-10s%-20s%-10s ",
"Client","Lawyer","Hours","Fee","%Discount","Reg Hours",
"Discounted Hours","Total Fee");
System.out.printf("------------------------------------------");
System.out.printf("------------------------------------------ ");
//calculations
for (int i = 0; i < num_clients; i++) {
total_hours+=hours[i];
//check if hours is greater than basehours
if(hours[i]>basehours[i])
{
discount_hours= hours[i]-basehours[i];
//calculate discount
discount_amount=discount_hours*fee[i]*(disc[i]/100.0);
net_amount=hours[i]*fee[i]-discount_amount;
}
else
{
discount_hours=0;
net_amount=hours[i]*fee[i];
}
regular_hours=hours[i]-discount_hours;
total_income+=net_amount;
//print on console
System.out.printf("%-10s%-10s%-10.2f%-10.2f%-10.2f%-10.2f%-20.2f%-10.2f ",
client[i],lawyer[i],hours[i],fee[i],
disc[i],regular_hours,discount_hours,net_amount);
System.out.printf("------------------------------------------");
System.out.printf("------------------------------------------ ");
}
System.out.println();
System.out.printf("%-20s%-20s ","Total Hours","Total Income");
System.out.printf("%-20.2f%-20.2f ",
total_hours,total_income);
System.out.printf("------------------------------------------");
System.out.printf("------------------------------------------ ");
}
}
------------------------------------------------------------------------------------------
Sample Output:
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 :34
Enter the base hours :250
Enter the fee for the first 250.00 hours :100
Enter the discount percentage:(5,10,20,25,...)10
------------------------------------------------------------------------------------
Enter the name of the client :Patel
Enter the name of the lawyer :Jason
Enter the hours :66
Enter the base hours :20
Enter the fee for the first 20.00 hours :300
Enter the discount percentage:(5,10,20,25,...)20
------------------------------------------------------------------------------------
Enter the name of the client :Joe
Enter the name of the lawyer :Jack
Enter the hours :89
Enter the base hours :45
Enter the fee for the first 45.00 hours :400
Enter the discount percentage:(5,10,20,25,...)4
------------------------------------------------------------------------------------
Client Lawyer Hours fFee %Discount Reg Hours Discounted Hours Total Fee
------------------------------------------------------------------------------------
Mary Alex 34.00 100.00 10.00 34.00 0.00 3400.00
------------------------------------------------------------------------------------
Patel Jason 66.00 300.00 20.00 20.00 46.00 17040.00
------------------------------------------------------------------------------------
Joe Jack 89.00 400.00 4.00 45.00 44.00 34896.00
------------------------------------------------------------------------------------
Total Hours Total Income
189.00 55336.00
------------------------------------------------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.