Code in JAVA and see attached images for information on classes and methods A company pays its personnel on a weekly basis. The personnel are of 4 types: FixedWeekly personnel are paid a fixed amount regardless of the number of hours worked ByTheHour personnel are paid by the hour and receive overtime pay for all hours worked in excess of 40 PercentOfSales personnel are paid a percentage of their sales FixedWeeklyPercentOfSales personnel receive a fixed amount plus a percentage of their sales. Create a class called Personnel. This class will represent the general concept of all personnel. All 4 types of personnel are considered Personnel. FixedWeeklyPercentOfSales personnel are considered to be PercentOfSales Personnel. The Personnel class will also be Payable. You will need to create the Payable interface. It will contain just one method called earnings(). Test Run Personnel processed polymorphically: FixedWeekly personnel: Harry Clark social security number: 111-11-1111 weekly salary: $800.00 earned $800.00 ByTheHour personnel: Katie Brown social security number: 222-22-2222 ByTheHour wage: $16.75; hours worked: 40.00 earned $670.00 PercentOfSales personnel: Joan White social security number: 333-33-3333 gross sales: $10,000.00; PercentOfSales rate: 0.06 earned $600.00 FixedWeeklyPercentOfSales personnel: Bob Green social security number: 444-44-4444

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter4: Making Decisions
Section: Chapter Questions
Problem 16RQ
icon
Related questions
Question

Code in JAVA and see attached images for information on classes and methods

A company pays its personnel on a weekly basis.  The personnel are of 4 types: 

FixedWeekly personnel are paid a fixed amount regardless of the number of hours worked
ByTheHour  personnel are paid by the hour and receive overtime pay for all hours worked in excess of 40
PercentOfSales personnel are paid a percentage of their sales
FixedWeeklyPercentOfSales personnel receive a fixed amount plus a percentage of their sales.

Create a class called Personnel.  This class will represent the general concept of all personnel.  All 4 types of personnel are considered Personnel.  FixedWeeklyPercentOfSales personnel are considered to be PercentOfSales Personnel.  

The Personnel class will also be Payable.  You will need to create the Payable interface.  It will contain just one method called earnings().  

Test Run

Personnel processed polymorphically:

FixedWeekly personnel: Harry Clark
social security number: 111-11-1111
weekly salary: $800.00
earned $800.00

ByTheHour personnel: Katie Brown
social security number: 222-22-2222
ByTheHour wage: $16.75; hours worked: 40.00
earned $670.00

PercentOfSales personnel: Joan White
social security number: 333-33-3333
gross sales: $10,000.00; PercentOfSales rate: 0.06
earned $600.00

FixedWeeklyPercentOfSales personnel: Bob Green
social security number: 444-44-4444
gross sales: $5,000.00; PercentOfSales rate: 0.04; FixedWeekly salary: $300.00
new FixedWeekly salary with 10% increase is: $330.00
earned $530.00

 

 

 

 

Write a class to test your inheritance hierarchy. In that class do the following:
Create 4 Personnel objects. Use the below information
The Test Data is in a File called personnel.txt and contains the following data:
fixed Harry Clark 111-11-1111 800.00
hour Katie Brown 222-22-2222 16.75 40
percent Joan White, 333-33-3333 10000 .06
fxdpercent Bob Green 444-44-4444 5000 .04 300
The first token in each line in the data file represents a code for the type of Personnel
fixed – FixedWeekly
hour – ByTheHour
percent – PercentOfSales
fxdpercent - FixedWeeklyPercentOfSales
Reading the data file (Suggested approach.if you use a different approach make sure you
thoroughly document your approach)
Read a line at a time from the file
store each line in an array of Strings
Tokenize (split) the string (In the Java API, learn about using the split method for a String)
Instantiate the correct type of Personnel object based on a personnel code
store the object in an array of Personnel so that you can access them polymorphically.
Process these objects polymorphically displaying a string representation for all Personnel and
their earnings as shown at the end of this document (i.e. loop through your array of Personnel,
this could have been a file that contained thousands of Personnel)
You will need to perform special processing on FixedWeeklyPercentOfSales objects in
that we have decided to give them a 10% permanent increase to their FixedWeekly
salary. (check out the instanceof operator in java.)
Handle exceptions
FileNotFound
NumberFormatException
Any other appropriate exceptions
Output
Write your output to the screen (copy and paste that output to the bottom of your test
class).
Write your output to a textfile named "payroll.txt".
O O
Transcribed Image Text:Write a class to test your inheritance hierarchy. In that class do the following: Create 4 Personnel objects. Use the below information The Test Data is in a File called personnel.txt and contains the following data: fixed Harry Clark 111-11-1111 800.00 hour Katie Brown 222-22-2222 16.75 40 percent Joan White, 333-33-3333 10000 .06 fxdpercent Bob Green 444-44-4444 5000 .04 300 The first token in each line in the data file represents a code for the type of Personnel fixed – FixedWeekly hour – ByTheHour percent – PercentOfSales fxdpercent - FixedWeeklyPercentOfSales Reading the data file (Suggested approach.if you use a different approach make sure you thoroughly document your approach) Read a line at a time from the file store each line in an array of Strings Tokenize (split) the string (In the Java API, learn about using the split method for a String) Instantiate the correct type of Personnel object based on a personnel code store the object in an array of Personnel so that you can access them polymorphically. Process these objects polymorphically displaying a string representation for all Personnel and their earnings as shown at the end of this document (i.e. loop through your array of Personnel, this could have been a file that contained thousands of Personnel) You will need to perform special processing on FixedWeeklyPercentOfSales objects in that we have decided to give them a 10% permanent increase to their FixedWeekly salary. (check out the instanceof operator in java.) Handle exceptions FileNotFound NumberFormatException Any other appropriate exceptions Output Write your output to the screen (copy and paste that output to the bottom of your test class). Write your output to a textfile named "payroll.txt". O O
Personnel have a first name, last name, and social security number. FixedWeekly personnel have a first
name, last name, social security number and fixed weekly salary. ByTheHour personnel have a first
name, last name, social security number, an hourly wage, and number of hours worked. PercentOfSales
personnel have a first name, last name, social security number, gross sales amount, and commission
rate. FixedWeeklyPercentOfSales personnel have a first name, last name, social security number, gross
sales amount, commission rate and a fixed weekly salary.
The Personnel class will contain an appropriate 3 parameter constructor and a default constructor,
appropriate accessors and mutators, toString, and equals methods. Two Personnel will be considered
equal if their earnings are the same. It will also contain an earnings method which must be
implemented by the subclasses. The constructor will validate that the social security number is in the
proper format (999-99-9999). If not in the proper format, the constructor will assign XXX-XX-XXXX for
the social security number. (you can do this using appropriate methods of the String class or by using
what are called Regular Expressions..it might be easier to just use methods from the String class rather
than learning about Regular Expressions - your choice)
The FixedWeekly class will contain an appropriate 4 parameter constructor and a default constructor,
appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you
need to override or simply inherit methods from the super class. The constructor will validate that the
fixed weekly salary is not negative. If the salary figure is negative the fixed weekly salary value will be set
to 0.
The ByTheHour class will contain an appropriate 5 parameter constructor and a default constructor,
appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you
need to override or simply inherit methods from the super class. The constructor will validate that the
hourly wage is not negative and that the hours worked is between 0 and 60 inclusive. If the hourly wage
is negative set the hourly wage to 0. If hours worked is not in the proper range, set the hours worked to
0.
The PercentOfSales class will contain an appropriate 5 parameter constructor and a default constructor,
appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you
need to override or simply inherit methods from the super class. The constructor will validate that the
gross sales amount is not negative and that the commission rate is a value between 0.0 and 1.0 inclusive.
If these conditions are not met then set the appropriate variable values to 0.
The FixedWeeklyPercentOfSales class will contain an appropriate 6 parameter constructor and a default
constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide
whether you need to override or simply inherit methods from the super class. The constructor will
validate that the fixed weekly salary amount is not negative. If the fixed weekly salary is negative set the
appropriate variable value to 0.
Transcribed Image Text:Personnel have a first name, last name, and social security number. FixedWeekly personnel have a first name, last name, social security number and fixed weekly salary. ByTheHour personnel have a first name, last name, social security number, an hourly wage, and number of hours worked. PercentOfSales personnel have a first name, last name, social security number, gross sales amount, and commission rate. FixedWeeklyPercentOfSales personnel have a first name, last name, social security number, gross sales amount, commission rate and a fixed weekly salary. The Personnel class will contain an appropriate 3 parameter constructor and a default constructor, appropriate accessors and mutators, toString, and equals methods. Two Personnel will be considered equal if their earnings are the same. It will also contain an earnings method which must be implemented by the subclasses. The constructor will validate that the social security number is in the proper format (999-99-9999). If not in the proper format, the constructor will assign XXX-XX-XXXX for the social security number. (you can do this using appropriate methods of the String class or by using what are called Regular Expressions..it might be easier to just use methods from the String class rather than learning about Regular Expressions - your choice) The FixedWeekly class will contain an appropriate 4 parameter constructor and a default constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you need to override or simply inherit methods from the super class. The constructor will validate that the fixed weekly salary is not negative. If the salary figure is negative the fixed weekly salary value will be set to 0. The ByTheHour class will contain an appropriate 5 parameter constructor and a default constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you need to override or simply inherit methods from the super class. The constructor will validate that the hourly wage is not negative and that the hours worked is between 0 and 60 inclusive. If the hourly wage is negative set the hourly wage to 0. If hours worked is not in the proper range, set the hours worked to 0. The PercentOfSales class will contain an appropriate 5 parameter constructor and a default constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you need to override or simply inherit methods from the super class. The constructor will validate that the gross sales amount is not negative and that the commission rate is a value between 0.0 and 1.0 inclusive. If these conditions are not met then set the appropriate variable values to 0. The FixedWeeklyPercentOfSales class will contain an appropriate 6 parameter constructor and a default constructor, appropriate accessors and mutators, earnings, toString, and equals methods. You decide whether you need to override or simply inherit methods from the super class. The constructor will validate that the fixed weekly salary amount is not negative. If the fixed weekly salary is negative set the appropriate variable value to 0.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

My output returns "D:\personnel.txt does not exist." instead of providing the proper test run. Is it not reading the file from readFile?

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning