Question

In: Computer Science

Create a class Client. Your Client class should include the following attributes: Company Name (string) Company...

Create a class Client. Your Client class should include the following attributes:

Company Name (string)

Company id (string)

Billing address (string)

Billing city (string)

Billing state (string)

Write a constructor to initialize the above Employee attributes.

Create another class HourlyClient that inherits from the Client class.   HourClient must use the inherited parent class variables and add in hourlyRate and hoursBilled. Your Hourly Client class should contain a constructor that calls the constructor from the Client class to initialize the common instance variables but also initializes the hourlyRate and hoursBilled. Add a billing method to HourlyClient to calculate the amount due from a service provided. Note that billing amount is hourlyRate * hoursBilled

Create a test class that prompts the user for the information for five hourly clients, creates an arraylist of 5 hourly client objects, display the attributes and billing for each of the five hourly clients. Display the company name and billing amount for each company and the total billing amount for all five companies.

Remember to submit your pseudocode algorithm

Solutions

Expert Solution

package Array;

import java.util.ArrayList;

// Defines a class to store client information

class Client

{

// Instance variable to store client information

String companyName;

String companyId;

String billingAddress;

String billingCity;

String billingState;

// Default constructor to assign default values

// to instance variable

Client()

{

companyName = companyId = billingAddress =

billingCity = billingState = "";

}// End of default constructor

// Parameterized constructor to assign parameter values

// to instance variables

Client(String cn, String ci, String ba, String bc, String bs)

{

companyName = cn;

companyId = ci;

billingAddress = ba;

billingCity = bc;

billingState = bs;

}// End of parameterized constructor

// Overloads toString() method to return client information

public String toString()

{

return "\n\n Company Name: " + companyName +

"\n Company ID: " + companyId +

"\n Billing Address: " + billingAddress +

"\n Billing City: " + billingCity +

"\n Billing State: " + billingState;

}// End of method

}// End of class Client

// Defines a derived class HourlyClient extended

// from super Client class  

class HourlyClient extends Client

{

// Instance variable to store client information

double hourlyRate;

double hoursBilled;

double billingAmount;

// Default constructor to assign default values to instance variable

HourlyClient()

{

// Calls the super class default constructor

super();

hourlyRate = hoursBilled = 0.0;

}// End of default constructor

// Parameterized constructor to assign parameter values

// to instance variables

HourlyClient(String cn, String ci, String ba,

String bc, String bs, double hr, double hb)

{

// Calls the super class parameterized constructor

super(cn, ci, ba, bc, bs);

hourlyRate = hr;

hoursBilled = hb;

billingAmount = 0.0;

}// End of parameterized constructor

// Method to calculate billing amount

void calculateAmount()

{

billingAmount = hourlyRate * hoursBilled;

}// End of method

// Overloads toString() method to return hourly client information

public String toString()

{

// Calls the super class toString() method

// Concatenates hourly client information

return super.toString() +

"\n Hourly Rate: " + hourlyRate +

"\n Hours Billed: " + hoursBilled +

"\n Billing Amount: " + billingAmount;

}// End of method

}// End of class HourlyClient

// Driver class definition

public class ArrayListClient

{

// main method definition

public static void main(String ss[])

{

// Creates a string array and stores company name

String companyName[] = {"Sujan", "Ambica", "Sanjibani",

"Sagar", "Ambuja"};

// Creates a string array and stores company id

String companyId[] = {"111", "123", "256", "568", "898"};

// Creates a string array and stores billing address

String billingAddress[] = {"BBSR", "BAM", "RGDA",

"RKL", "CTC"};

// Creates a string array and stores billing city

String billingCity [] = {"Berhampur", "Bhubaneswar",

"Rayagada", "Rourkela", "Cuttack"};

// Creates a string array and stores billing state

String billingState [] = {"Orissa", "Bihar", "Westbangal",

"Bihar", "Jammu"};

// Creates a double array and stores hourly rate

double hourlyRate [] = {89.56, 55.23, 78.89, 33.45, 91.2};

// Creates a double array and stores hours billed

double hoursBilled [] ={12, 20, 10, 45, 36};

// Creates an array of object of class HourlyClient

// of size 5

HourlyClient hc[] = new HourlyClient[5];

// Creates an array list to store class HourlyClient object

ArrayList<HourlyClient> hcArray =

new ArrayList<HourlyClient>();

// Loops till number of company

for(int c = 0; c < hc.length; c++)

{

// Creates an object of class HourlyClient using

// parameterized constructor and adds it to

// array list

hcArray.add(new HourlyClient(companyName[c],

companyId[c], billingAddress[c],

billingCity[c], billingState[c],

hourlyRate[c], hoursBilled[c]));

// Calls the method to calculate amount

hcArray.get(c).calculateAmount();

// Displays each object information

System.out.println(hcArray.get(c));

}// End of for loop

}// End of main method

}// End of class

Sample Output:

Company Name: Sujan

Company ID: 111

Billing Address: BBSR

Billing City: Berhampur

Billing State: Orissa

Hourly Rate: 89.56

Hours Billed: 12.0

Billing Amount: 1074.72

Company Name: Ambica

Company ID: 123

Billing Address: BAM

Billing City: Bhubaneswar

Billing State: Bihar

Hourly Rate: 55.23

Hours Billed: 20.0

Billing Amount: 1104.6

Company Name: Sanjibani

Company ID: 256

Billing Address: RGDA

Billing City: Rayagada

Billing State: Westbangal

Hourly Rate: 78.89

Hours Billed: 10.0

Billing Amount: 788.9

Company Name: Sagar

Company ID: 568

Billing Address: RKL

Billing City: Rourkela

Billing State: Bihar

Hourly Rate: 33.45

Hours Billed: 45.0

Billing Amount: 1505.2500000000002

Company Name: Ambuja

Company ID: 898

Billing Address: CTC

Billing City: Cuttack

Billing State: Jammu

Hourly Rate: 91.2

Hours Billed: 36.0

Billing Amount: 3283.2000000000003


Related Solutions

Using JAVA Create a class Client. Your Client class should include the following attributes: Company Name...
Using JAVA Create a class Client. Your Client class should include the following attributes: Company Name (string) Company id (string) Billing address (string) Billing city (string) Billing state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyClient that inherits from the Client class.   HourClient must use the inherited parent class variables and add in hourlyRate and hoursBilled. Your Hourly Client class should contain a constructor that calls the constructor from the Client class to initialize...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyEmployee that inherits from the Employee class.   HourEmployee must use the inherited parent class variables and add in HourlyRate and HoursWorked. Your HourEmployee class should contain a constructor that calls the constructor from the...
Implement a class Student, including the following attributes and methods: Two public attributes name(String) and score...
Implement a class Student, including the following attributes and methods: Two public attributes name(String) and score (int). A constructor expects a name as a parameter. A method getLevel to get the level(char) of the student. score level table: A: score >= 90 B: score >= 80 and < 90 C: score >= 60 and < 80 D: score < 60 Example:          Student student = new Student("Zack"); student.score = 10; student.getLevel(); // should be 'D'. student.score = 60; student.getLevel(); //...
In C++ Demonstrate inheritance. Create an Airplane class with the following attributes: • manufacturer : string...
In C++ Demonstrate inheritance. Create an Airplane class with the following attributes: • manufacturer : string • speed : float Create a FigherPlane class that inherits from the Airplane class and adds the following attributes: • numberOfMissiles : short
Create a Class to contain a customer order Create attributes of that class to store Company...
Create a Class to contain a customer order Create attributes of that class to store Company Name, Address and Sales Tax. Create a public property for each of these attributes. Create a class constructor without parameters that initializes the attributes to default values. Create a class constructor with parameters that initializes the attributes to the passed in parameter values. Create a behavior of that class to generate a welcome message that includes the company name. Create a Class to contain...
Specifications Create an abstract Employee class that provides private attributes for the first name, last name,...
Specifications Create an abstract Employee class that provides private attributes for the first name, last name, email address, and social security number. This class should provide functions that set and return the employee’s first name, last name, email address, and social security number. This class has a function: get_net_income which returns 0. Create a Manager class that inherits the Employee class. This class should add private attributes for years of experience and the annual salary. This class should also provide...
A. Create a Dollar currency class with two integer attributes and one string attribute, all of...
A. Create a Dollar currency class with two integer attributes and one string attribute, all of which are non-public. The int attributes will represent whole part (or currency note value) and fractional part (or currency coin value) such that 100 fractional parts equals 1 whole part. The string attribute will represent the currency name. B. Create a CIS22C Dollar derived/inherited class with one additional non-public double attribute to represent the conversion factor from/to US Dollar. The value of the conversion...
JAVA Program Create a class called SoccerPlayer Create 4 private attributes: First Name, Last Name, Games,...
JAVA Program Create a class called SoccerPlayer Create 4 private attributes: First Name, Last Name, Games, and Goals Have two constructors Constructor 1 – default constructor; all values to "NONE" or zero Constructor 2 – accepts input of first name, last name, games and goals. Create get and set methods for each of the four attributes Create a method the returns a double that calculates the average goals per game This method checks for zero games played: If there are...
PYTHON PLEASE: Construct a class “Monster” with the following attributes: self.name (a string) self.type (a string,...
PYTHON PLEASE: Construct a class “Monster” with the following attributes: self.name (a string) self.type (a string, default is ‘Normal’) self.current_hp (int, starts out equal to max_hp) self.max_hp (int, is given as input when the class instance is created, default is 20) self.exp (int, starts at 0, is increased by fighting) self.attacks (a dict of all known attacks) self.possible_attacks (a dictionary of all possible attacks) The dictionary of possible_attacks will map the name of an attack (the key) to how many...
Create a class named Horse that contains the following data fields: name - of type String...
Create a class named Horse that contains the following data fields: name - of type String color - of type String birthYear - of type int Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field, races (of type int), that holds the number of races in which the horse has competed and additional methods to get and set the new field. ------------------------------------ DemoHorses.java public class DemoHorses {     public static void...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT