Question

Use Java To(with Explaination of Steps Please): You’re given a class Employee that represents a worker...

Use Java To(with Explaination of Steps Please):

You’re given a class Employee that represents a worker in some unknown industry.Each employee has a name , balance and an hourly rate that is unique to them. So Worker1 can have a rate of $5 per hour and Worker2 can have $8 per hour. There are 2 constructors – one that lets you specify the name, a starting balance and the rate,and another that only lets you specify the name and rate and defaults the balance to 0. There are 3 methods for the Employee class – a “ work(int hours) ” method that adds money to that worker's balance, a “ spend (double money) ” method, and a “ printInfo() ” method which prints that workers name, rate, and balance. Now write a new program ( EmployeeDriver ) that creates 3 workers, assigns them to work a few shifts, spend some of their money, then prints out the information for each worker. Make use of all of the constructors and instance variables and methods available in the Employee.

Example run : (not all methods are used in this example)

java Employee creating employees…

Employee name is Bob, rate is 50, balance is 3000

Employee name is Rob, rate is 20 , balance is 1000

Employee name is Tom, rate is 10, balance is 0 working

employees a few hours…

Employee name is Bob, rate is 50, balance is 3500

Employee name is Rob, rate is 20, balance is 1400

Homework Answers

Answer #1

Hi, Please find my implementation.

Please let me know in case of any issue.

######### Employee.java #############

public class Employee {

   // instance variables

   private String name;

   private double rate;

   private double balance;

   // constructor

   public Employee(String name, double rate, double balance) {

       this.name = name;

       this.rate = rate;

       this.balance = balance;

   }

   public Employee(String name, double rate) {

       this.name = name;

       this.rate = rate;

       this.balance = 0;

   }

  

   public void work(int hours){

       balance = balance + rate*hours;

   }

  

   public void spend (double money){

       balance = balance - money;

   }

  

   public void printInfo(){

       System.out.println("Employee name is "+name+", rate is "+rate+", balance is "+balance);

   }

}

###################   EmployeeDriver.java ###############

public class EmployeeDriver {

   public static void main(String[] args) {

      

       // creating three Employee Objects

       Employee emp1 = new Employee("Bob", 50, 5000);

       Employee emp2 = new Employee("Rob", 20, 1000);

       Employee emp3 = new Employee("Rob", 10);

       emp1.printInfo();

       emp2.printInfo();

       emp3.printInfo();

       emp1.work(10);

       emp1.printInfo();

       emp2.work(20);

       emp2.printInfo();

       emp3.work(40);

       emp3.printInfo();

      

       emp2.spend(700);

       emp2.printInfo();

   }

}

/*

Sample run:

Employee name is Bob, rate is 50.0, balance is 5000.0

Employee name is Rob, rate is 20.0, balance is 1000.0

Employee name is Rob, rate is 10.0, balance is 0.0

Employee name is Bob, rate is 50.0, balance is 5500.0

Employee name is Rob, rate is 20.0, balance is 1400.0

Employee name is Rob, rate is 10.0, balance is 400.0

Employee name is Rob, rate is 20.0, balance is 700.0

*/

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using Java language.... Polymorphism of Interfaces : Take the Account class from the last chapter and...
Using Java language.... Polymorphism of Interfaces : Take the Account class from the last chapter and make a java program for your bank. However, there is another type of customer that may not have money in the bank and may not in fact have a back account with this bank at all, but may have a loan here. Make another class in the application you are making called CarLoan. Carloan's should have a name, amount owed, a rate, and a...
Please answer in JAVA IDS 401 Assignment 4 Deadline In order to receive full credit, this...
Please answer in JAVA IDS 401 Assignment 4 Deadline In order to receive full credit, this assignment must be submitted by the deadline on Blackboard. Submitting your assignment early is recommended, in case problems arise with the submission process. Late submissions will be accepted (but penalized 10pts for each day late) up to one week after the submission deadline. After that, assignments will not be accepted. Assignment The object of this assignment is to construct a mini-banking system that helps...
Objectives:The focus of this assignment is to create and use a recursive method given a moderately...
Objectives:The focus of this assignment is to create and use a recursive method given a moderately difficult problem. Program Description: This project will alter the EmployeeManager to add a search feature, allowing the user to find an Employee by a substring of their name. This will be done by implementing the Rabin-Karp algorithm. A total of seven classes are required. Employee (From previous assignment) HourlyEmployee (From previous assignment) SalaryEmployee (From previous assignment) CommissionEmployee (From previous assignment) EmployeeManager (Altered from previous...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you start doing anything… This project involves implementing a simple university personnel management program. The program contains two different kinds of objects: students and faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of the object. For example, a student has a GPA, while a faculty has a title and department...
***Programming language is Java. After looking at this scenario please look over the requirements at the...
***Programming language is Java. After looking at this scenario please look over the requirements at the bottom (in bold) THIS IS ALL THAT WAS PROVIDED. PLEASE SPECIFY ANY QUESTIONS IF THIS IS NOT CLEAR (don't just say more info, be specific)*** GMU in partnership with a local sports camp is offering a swimming camp for ages 10-18. GMU plans to make it a regular event, possibly once a quarter. You have been tasked to create an object-oriented solution to register,...
The Harborside Inn, located on the New England coast, is a 125-room luxury hotel. The inn's...
The Harborside Inn, located on the New England coast, is a 125-room luxury hotel. The inn's guests are predominantly upper middle class in that the going rate is about $100 per day per person. The hotel grounds include 30 acres of lawns and gardens. Their nine-hole golf course winds its way around a picturesque trout pond. The hotel grounds were meticulously cared for and yet efforts at cultivating beauty could not match the natural beauty which was so much a...
Team 5 answer the questions What are 4 key things you learned about the topic from...
Team 5 answer the questions What are 4 key things you learned about the topic from reading their paper? How does the topic relate to you and your current or past job? Critique the paper in terms of the organization and quality. Incentive Systems             In this paper, we will focus primarily on financial rewards that companies use to attract, retain and motivate the brightest and most talented candidates in the labor market. By providing a reward system that...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
2. SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to...
2. SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to be used as a basis for class discussion rather than as an illustration of the effective or ineffective handling of an administrative situation. The name of the company is disguised. INTRODUCTION In light of demographic concerns, in 2012, the Japanese government initiated an effort to change the work environment in order to secure the workforce of the future. Japan is world renowned for its...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT