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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started