Question: All i need is for someone to add the appropriate comments to make this code accurate. Simply label constructors, class variables, say what methods do,

All i need is for someone to add the appropriate comments to make this code accurate. Simply label constructors, class variables, say what methods do, point out class changes, etc. Just add comments :)

public class Client {

String companyName;

String companyId;

String billingAddress;

String billingCity;

String billingState;

public Client(String companyName, String companyId, String billingAddress, String billingCity,

String billingState) {

this.companyName = companyName;

this.companyId = companyId;

this.billingAddress = billingAddress;

this.billingCity = billingCity;

this.billingState = billingState;

}

}

HourlyClient.java file:

public class HourlyClient extends Client{

double hoursBilled;

double hourlyRate;

public HourlyClient(String companyName, String companyId, String billingAddress, String billingCity,

String billingState, double hoursBilled, double hourlyRate) {

super(companyName, companyId, billingAddress, billingCity, billingState);

this.hoursBilled = hoursBilled;

this.hourlyRate = hourlyRate;

}

public double billingDue() {

return hoursBilled * hourlyRate ;

}

}

TestClient.java file:

import java.util.*;

public class TestClient {

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner sc = new Scanner(System.in);

ArrayList clients = new ArrayList();

String companyName;

String companyId;

String billingAddress;

String billingCity;

String billingState;

double hoursBilled;

double hourlyRate;

for(int i = 0 ; i < 5 ;i++) {

System.out.println("Enter the information about hourly client " + (i+1));

System.out.print("Company Name : ");

companyName = sc.nextLine();

System.out.print("Company Id : ");

companyId = sc.nextLine();

System.out.print("Billing Address : ");

billingAddress = sc.nextLine();

System.out.print("billingState : ");

billingState = sc.nextLine();

System.out.print("billingCity : ");

billingCity = sc.nextLine();

System.out.print("Hourly rate:");

hoursBilled = sc.nextDouble();

System.out.print("Hours billed:");

hourlyRate = sc.nextDouble();

sc.nextLine();

HourlyClient client = new HourlyClient(companyName, companyId, billingAddress, billingCity, billingState, hoursBilled, hourlyRate);

clients.add(client);

}

double totalBillingAmount = 0.0 ;

for(HourlyClient c : clients) {

System.out.printf("CompanyName : %s\tbillingAmount : %.2f ", c.companyName, c.billingDue());

totalBillingAmount += c.billingDue();

}

System.out.printf(" The total billing amount for all 5 companies : %.2f", totalBillingAmount);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!