In java Note: A shell has been provided to you. You can deviate from the shell a
ID: 3729409 • 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.
Edit FoHelo Ihis pnogran genaratas a surnary raport for the ast Les Firn Clients are charged based on the nurber of hours The provided disccunt is offered by cach individual lawyer and it could vary fron onc layer to anather How any clients á you have Enter the nac of the client: Mary Enter the hours:5 Enter the base hours: 258 Enter the discount percontagc:(5, 1e, 28, 25,...) 18 Enter the nare of the client: Patel Fnter the nate af the 1ayer 850n Inter the hours65 Enter the base huurs 20 Enter tha F Enter th discount percentoRc:(5, 1e, 28. 25....) 20 Enter the nare of the 1ient ; Jue Enter the nane at the layr: Jack Enter the hours : 89 Fnter the base hours: 15 Lnter the fee for the first 45. houIns:403 Enter the discount percentage:(5, 18, 20, 254 The reprt is rey, Hit e key to vies it. Client, Lenyer Hours ree %Discount Rec Hours Discountel Hours Nay 4.aa 1aO a Patel Json 56. 380.8 20.80 16,00 17640·00 loe ack B9.03 480.9e 4.03 45.90 44.00 34896.80 Total Hours Total InconeExplanation / Answer
package com;
import java.util.Scanner;
public class LegalClinic {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("How many Clients do you have");
int n=sc.nextInt();
Clinic []c=new Clinic[n];
for(int i=0;i<n;i++)
{
sc.nextLine();
String nameC,nameA;
c[i]=new Clinic();
System.out.println("Enter the name of the Client");
nameC=sc.nextLine();
c[i].setClient(nameC);
System.out.println("Enter the name of the Attorney");
nameA=sc.nextLine();
c[i].setAttorney(nameA);
System.out.println("Enter the hours");
c[i].setHours(sc.nextInt());
sc.nextLine();
System.out.println("Enter the base hours");
c[i].setBase_hr(sc.nextInt());
System.out.println("Enter the fee for 1st "+c[i].getBase_hr()+" hours");
c[i].setFee(sc.nextInt());
System.out.println("Enter the Discout percentage (5,10,15,20....)");
c[i].setDiscount(sc.nextInt());
c[i].Charges(c[i]);
}
System.out.println("Report is ready hit enter to view");
String s=sc.nextLine();
printreport(c,n);
}
public static void printreport(Clinic c[],int n)
{
double sum=0;
int hr=0;
System.out.println("CLIENT Attorney Hours Fee %Discount Reg Hours DiscountedHours TotalFee");
System.out.println();
for(int i=0;i<n;i++)
{
System.out.print(c[i].getClient());
System.out.print(" "+c[i].getAttorney());
System.out.print(" "+c[i].getHours());
System.out.print(" "+c[i].getFee());
System.out.print(" "+c[i].getDiscount());
System.out.print(" "+c[i].getBase_hr());
if(c[i].getHours()>c[i].getBase_hr())
System.out.print(" "+(c[i].getHours()-c[i].getBase_hr()));
else
System.out.print(" "+0);
System.out.print(" "+c[i].getTotalfee());
sum=sum+c[i].getTotalfee();
hr=hr+c[i].getHours();
System.out.println();
}
System.out.print("Total hours TotalIncome");
System.out.println();
System.out.print(hr+" "+sum);
}
}
------------------------------------------------------------------Clinic class
package com;
public class Clinic {
String Client;
String Attorney;
int hours;
int base_hr;
double fee;
double discount;
double totalfee;
public double getTotalfee() {
return totalfee;
}
public void setTotalfee(double totalfee) {
this.totalfee = totalfee;
}
public String getClient() {
return Client;
}
public void setClient(String client) {
Client = client;
}
public String getAttorney() {
return Attorney;
}
public void setAttorney(String attorney) {
Attorney = attorney;
}
public int getHours() {
return hours;
}
public void setHours(int hours) {
this.hours = hours;
}
public int getBase_hr() {
return base_hr;
}
public void setBase_hr(int base_hr) {
this.base_hr = base_hr;
}
public double getFee() {
return fee;
}
public void setFee(double fee) {
this.fee = fee;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
public void Charges(Clinic c)
{
double totalCharge,x;
if(c.getHours()>c.getBase_hr())
{
totalCharge=c.getBase_hr()*c.getFee();
x=((c.getHours()-c.getBase_hr())*c.getFee())*(100-c.getDiscount());
x=x/100;
totalCharge=totalCharge+x;
}
else
{
totalCharge=c.getHours()*c.getFee();
}
c.setTotalfee(totalCharge);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.