Write a class named Employee that has the following fields: name. The name field
ID: 3649101 • Letter: W
Question
Write a class named Employee that has the following fields:name. The name field is a String object that holds the employee's name.
idNumber. The idNumber is an int that holds the employee's ID number.
department. The department field is a String object that holds the name of the department where
the employee works.
position. The position field is a String object that holds the employee's job title.
Write appropriate mutator methods that store values in these fields and accessor methods that return the values in these fields. Once you have written the class, write a separate program that creates three Employee objects. Ask the user for the data. Use the following data as example.
Explanation / Answer
public class Employee { String name; String id; double salary; int age; String position; void display() { System.out.println("Employee Name:"+ "Jack"); //output strings System.out.println("Employee Id:"+id); System.out.printf("Salary:$%.2f ",60000); System.out.println("Employee Age:"+43); System.out.println("Employee Position:"+ "trashman"); //output strings } double getFedTax(double salary) { double fedTax=(salary-800)*.17; return fedTax; } int getSsTax(int rate,double salary) { double ssTax = salary*(rate/100); return (int)ssTax; //casting to int from double to have the correct return type //are you sure you want to return int for all the methods? } int getHealthFee(int rate,double salary) { double healthFee = (rate/100)*salary; return (int)healthFee; } int getInsurance(int age,double salary) { if (age=40 && age=50 && ageRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.