Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with my hospitlemployee.java and hospital.java code. thank you for the help! Chapter 5: Writing Classes CSC110AA and CIS163AA Ch 5 Program 1

I need help with my hospitlemployee.java and hospital.java code.
thank you for the help! image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Chapter 5: Writing Classes CSC110AA and CIS163AA Ch 5 Program 1 - HospitalEmployee and Hospital Classes Submit both HospitalEmployee.java and Hospital.java files. Include output in Hospital.java. [1] Implement a class called HospitalEmployee that represents an employee in a hospital based on the following informal UML diagram. Adhere to the UML diagram. Do not add additional instance variables or methods. Future assignments will be based on this assignment. HospitalEmployee private String empName private int empNumber private double hoursWorked private double payRate public HospitalEmployeel) default constructor. Assigns instance vanables a default value WempName to your name, ompNumber to 9999 hours Worked to pay Rate to o public String getEmpName() W returns the employees name public int gotEmpNumber() returns the employees number public double getHours Worked() W returns the hours an employee worked public double getPayRate() 2/ returns the employees pay rate public void setempName(String ename) sets the name for this employee public void setEmpNumber(int number) sets the employee number for this employee public void setHours Worked(double hours) sets the hours worked for this employee public void setPay Rato(double rate) // sets the pay rate for this employee public double calculateGrossPay() // calculates and returns the employee's gross pay (nours worked * pay rate) public void changeHours Worked double hours) changes the instance variable hours Worked by the hours Whours Worked should be updated to hours Worked - hours public void changePayRate(double amount) W/changes the instance variabile payRate by the amount payRate should be updated to paypale amount public double calculateBonus(String rating) returns 500 it rating is excellent turns 300 rating satisfactory W All other ratings return public String to String I returns the current state of this employee as String w (current values of intance vascalied the current public double calculateGrossPay() // calculates and returns the employee's gross pay (hours worked "pay rate) public void changeHoursWorked(double hours) // changes the instance variable hoursWorked by the hours // hoursWorked should be updated to hoursWorked + hours. public void changePayRate(double amount) 1/ changes the instance variable payRate by the amount // payRate should be updated to payRate + amount public double calculateBonus(String rating) il returns 500 it rating is excellent Il retums 300 if rating is "satisfactory" 1/ All other ratings retum public String toString 1/ returns the current state of this employee as a String 1/ (current values of all instance variables is called the current state) [2] Implement a tester class called Hospital.java to test (or use) methods in the HospitalEmployee class This file is also called a controller or driver program. Hospital should do the following in this order: create a HospitalEmployee called workert liditplay the state of object workert using the toString method Il set the pay rate of workert to 20.00 using the stayRate method Il display the state of object workert using the toString method change increase the pay rate of workert by 4.50 using the changePayRate method lichango/increase the hours worked of workert by 30 using the changeHours Worked method Il display the state of worker1 using the toString method display the name and gross pay at workert using getEmpane and calculate GrossPay methods Il display the name, bonus and total earnings of worker1 Use the calculateBonus method when calculating the bonus for worker 1 workert is an excellent employee The output from running Hospital should be as follows: (of course, your output will use your actual name) [2] Implement a tester class called Hospital.java to test (or use) methods in the HospitalEmployee class. This file is also called a controller or driver program. Hospital should do the following in this order: Il create a Hospital Employee called workert Il display the state of object worker1 using the toString method Il set the pay rate of worker1 to 20.00 using the setPayRate method I/display the state of object workert using the toString method lichange increase the pay rate of workert by 4.50 using the changePayRate method lichange increase the hours worked of workert by 30 using the change HoursWorked method Il display the state of worker1 using the toString method Il display the name and gross pay of workert using getEmpName and calculateGrossPay methods. I/display the name, bonus, and total earnings of worker1 Use the calculateBonus method when calculating the bonus for workert. workert is an excellent employee. The output from running Hospital should be as follows: (of course, your output will use your actual name) Welcome to our Hospital Beginning state of workeri: Employee: Your Name emplumber: 9999 hourWorked: 0.0 paydate 50.00 After pay rate 1 set: Employee: Your Name emplumber: 9999 hours orked: 0.0 payRate: $20.00 After pay rate and hours worked increases Employee: Your Name ettpaber9999 hours orked: 30.0 payrate: $24.50 Sployee Your Wansarned 5735.00 Acer bonus Youtsame received a bonus of $500.00 and earned a total of 31235.00 Goodny Hospital Employee class must be error free before you can use it in the tester class (Hospital) HospitalEmployee and Hospital need to be in the same folder package In Hospital create a currency format object to provide the nice $0.00 format uniberFormat FNumber formatorencitance To check if a string is equal to use the equals() method from the String class ratio quals excellent The output from running Hospital should be as follows: (of course, your output will use your actual name) Welcome to our Hospital Beginning state of workeri: Employee: Your Name empNumber: 9999 hoursWorked: 0.0 payRate: $0.00 After pay rate is set: Employee: Your Name empNumber: 9999 hoursWorked: 0.0 payRate: $20.00 After pay rate and hours worked increase: Employee: Your Name emp Number: 9999 hoursWorked: 30.0 payRate: $24.50 Employee Your Name earned $735.00 I After bonus: Your Name received a bonus of $500.00 and earned a total of $1235.00 Goodbye Hints: HospitalEmployee class must be error free before you can use it in the tester class (Hospital). HospitalEmployee and Hospital need to be in the same folder/package. In Hospital create a currency format object to provide the nice $0.00 format. Number Format cmt = NumberFormat.getCurrencyinstance(); To check if a String is equal to a value use the equals() method from the String class. if (rating.equals("excellent")) bonus = 500, else if (rating equals("satisfactory')) ) and so forth Opbaker

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions