Question

in Java Create an object class for the Employee Master (Employee). Select data types that will...

in Java Create an object class for the Employee Master (Employee). Select data types that will best represent the data to be stored. All variables are to be declared with a private access modifier. Provide assessor/mutator methods for each instance field. Also provide a display data method that displays all of the instance fields of the class. Be sure each field is preceded by the text name of the field.

Employee Master (Employee)

Employee Number                              Numeric                 0 decimals, max size 999,999

Department Number                          Numeric                 0 decimals, max size 9999

Last Name                                             String

First Name                                             String

Pay Type                                                Character              (Valid codes: H = Hourly, S = Salary)

Hourly Rate                                           Numeric                 2 decimals, max size: 9,999.99

Tax Marital Status                                Character              (Valid codes: S = Single, M = Married)

Number Exemptions                           Numeric                 0 decimals, max size 99

State Withholding Percentage          Numeric                 4 decimals, max size .9999

YTD Gross Earnings                              Numeric                 2 decimals, max size: 99,999,999.99

YTD Federal Taxes                               Numeric                 2 decimals, max size: 99,999,999.99

YTD Social Security Taxes                   Numeric                 2 decimals, max size: 99,999,999.99

YTD Medicare Taxes                            Numeric                 2 decimals, max size: 99,999,999.99

YTD State Taxes                                    Numeric                 2 decimals, max size: 99,999,999.99

YTD Deductions                                    Numeric                 2 decimals, max size: 99,999,999.99

Deduction 1 Code                                Character              (Valid: F = Fixed Amount, P = Percentage, N = None)

Deduction 1 Value *                           Numeric                 2 decimals, max size: 99,999.99

Deduction 2 Code                                Character              (Valid: F = Fixed Amount, P = Percentage, N = None)

Deduction 2 Value *                           Numeric                 2 decimals, max size: 99,999.99

Deduction 3 Code                                Character              (Valid: F = Fixed Amount, P = Percentage, N = None)

Deduction 3 Value *                           Numeric                 2 decimals, max size: 99,999.99

* Deduction value is a dollar amount if the deduction code is ‘F’ and a decimal percentage if the deduction code is ‘P’.

Create an application program called TestEmployee that creates an instance of the class, populates the instance variables either from using literal values (which I suggest) or user input, and then displays the class data using the display data method.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi , PFB the code, and let me know in case of any problem or if you need further explanation. Always happy to help

import java.text.DecimalFormat;
import java.util.Scanner;
public class Employee {
   private int empNum;
   private int depNum;
   private int numExemp;
   private long hrlRate;
   private long swp;
   private long ge;
   private long ft;
   private long sst;
   private long mt;
   private long st;
   private long ded;
   private long dv1;
   private long dv2;
   private long dv3;
   private char payType;
   private char mStat;
   private char dc1;
   private char dc2;
   private char dc3;
private String fname;
   private String lname;
public void input()
{
Scanner s= new Scanner(System.in);
System.out.println("Enter Employee Number\n");
empNum=s.nextInt();
System.out.println("Enter Department Number\n");
depNum=s.nextInt();
System.out.println("Enter Last Name\n");
lname=s.nextLine();
System.out.println("Enter First Name\n");
fname=s.nextLine();
System.out.println("Enter PayType\n");
payType=s.next().charAt(0);
System.out.println("Enter Hourly Rate\n");
hrlRate=s.nextLong();
System.out.println("Enter Tax Marital Status\n");
mStatus=s.next().charAt(0);
System.out.println("Enter Number Exemption\n");
numExem=s.nextInt();
System.out.println("Enter State Withholding Percentatge\n");
SWP=s.nextLong();
System.out.println("Enter YTD Gross Earnings\n");
ge=s.nextLong();
System.out.println("Enter YTD Federal Taxes\n ");
ft=s.nextLong();
System.out.println("Enter YTD Social Security Taxes\n");
sst=s.nextLong();
System.out.println("Enter YTD Medicare Taxes\n");
mt=s.nextLong();
System.out.println("Enter YTD State Taxes\n");
st=s.nextLong();
System.out.println("Enter YTD deductions\n");
ded=s.nextLong();
System.out.println("Enter Deduction 1 Code\n ");
dc1=s.next().charAt(0);
System.out.println("Enter Deduction 2 Value\n ");
dv1=s.nextLong();
System.out.println("Enter Deduction 2 Code\n ");
dc2=s.next().charAt(0);
System.out.println("Enter Deduction 2 Value\n ");
dv2=s.nextLong();
System.out.println("Enter Deduction 3 Code\n ");
dc3=s.next().charAt(0);
System.out.println("Enter Deduction 3 Value\n ");
dv3=s.nextLong();
}

public void displayData()
{
System.out.println("Employee Number\n" + empNum);
//empNum=s.nextInt();
System.out.println("\nEnter Department Number\n"+depNum);
//depNum=s.nextInt();
System.out.println("\nLast Name\n" + lname);
//lname=s.nextLine();
System.out.println("\nFirst Name\n"+fname);
//fname=s.nextLine();
System.out.println("\nPayType\n"+payType);
//payType=s.next().charAt(0);
DecimalFormat ft = new DecimalFormat("#.##");
System.out.println("\nHourly Rate\n"+ft.format(hrlRate));
//hrlRate=s.nextLong();
System.out.println("\nTax Marital Status\n"+mStatus);
//mStatus=s.next().charAt(0);
System.out.println("\nNumber Exemption\n"+numExem);
//numExem=s.nextInt();
ft = new DecimalFormat("#.####");
System.out.println("\nState Withholding Percentatge\n"+ft.format(SWP));
//SWP=s.nextLong();
ft = new DecimalFormat("#.##");
System.out.println("\nYTD Gross Earnings\n"+st.format(ge));
//ge=s.nextLong();
ft = new DecimalFormat("#.##");
System.out.println("\nYTD Federal Taxes\n"+ft.format(ft));
//ft=s.nextLong();
ft = new DecimalFormat("#.##");
System.out.println("\nEnter YTD Social Security Taxes\n"+ft.format(sst));
//sst=s.nextLong();
ft = new DecimalFormat("#.##");
System.out.println("\nYTD Medicare Taxes\n"+ft.format(mt));
//mt=s.nextLong();
ft = new DecimalFormat("#.##");
System.out.println("\nYTD State Taxes\n"+ft.format(st));
//st=s.nextLong();
ft = new DecimalFormat("#.##");
System.out.println("\nYTD deductions\n"+ft.format(ded));
//ded=s.nextLong();
System.out.println("\nDeduction 1 Code\n"+dc1);
//dc1=s.next().charAt(0);
ft = new DecimalFormat("#.##");
System.out.println("\nDeduction 2 Value\n"+ft.format(dv1));
//dv1=s.nextLong();
System.out.println("\nDeduction 2 Code\n"+dc2);
//dc2=s.next().charAt(0);
ft = new DecimalFormat("#.##");
System.out.println("\nEnter Deduction 2 Value\n"+ft.format(dv2));
//dv2=s.nextLong();
System.out.println("\nDeduction 3 Code\n"+dc3);
//dc3=s.next().charAt(0);
ft = new DecimalFormat("#.##");
System.out.println("\nDeduction 3 Value\n "+ft.format(dv3));
// dv3=s.nextLong();
}

public static void main(String[] args) {
  
Employee emp = new Employee();
emp.input();
emp.displayData();
  
}
}

Add a comment
Know the answer?
Add Answer to:
in Java Create an object class for the Employee Master (Employee). Select data types that will...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 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...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEm...

    Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEmployee, HourlyEmployee which extend the Employee class and implements that abstract method. A Salary Employee has a salary, a Commision Employee has a commission rate and total sales, and Hourly Employee as an hourly rate and hours worked Software Architecture: The Employee class is the abstract super class and must be instantiated by one of...

  • Code a complete Java program for the following payroll application: First, hard code the following data...

    Code a complete Java program for the following payroll application: First, hard code the following data for the object ‘Employee’ into 4 separate arrays: SSN: 478936762, 120981098, 344219081, 390846789, 345618902, 344090917 First name      : Robert, Thomas, Tim, Lee, Young, Ropal Last name       : Donal, Cook, Safrin, Matlo, Wang, Kishal Hourly rate     : 12.75, 29.12, 34.25, 9.45,   20.95, 45.10 Hours worked: 45,        40,        39,       20,      44,        10 These 4 arrays must be declared inside the class and not within any method....

  • Create a date class with attributes of month, day, and year. Create an employee class for...

    Create a date class with attributes of month, day, and year. Create an employee class for storing information related to employee information for the CS1C Corporation. This class should contain the employee’s name, employee’s Id, phone number, age, gender, job title, salary, and hire date. You should write a series of member functions that change the employee’s name, employee’s Id, phone number, age, job title, salary, and hire date. You should use your date class (composition) when accessing hire date....

  • Create a date class with attributes of month, day, and year. Create an employee class for...

    Create a date class with attributes of month, day, and year. Create an employee class for storing information related to employee information for the CS1C Corporation. This class should contain the employee’s name, employee’s Id, phone number, age, gender, job title, salary, and hire date. You should write a series of member functions that change the employee’s name, employee’s Id, phone number, age, job title, salary, and hire date. You should use your date class (composition) when accessing hire date....

  • I need help with this one method in java. Here are the guidelines. Only public Employee[]...

    I need help with this one method in java. Here are the guidelines. Only public Employee[] findAllBySubstring(String find). EmployeeManager EmployeeManager - employees : Employee[] - employeeMax : final int = 10 -currentEmployees : int <<constructor>> EmployeeManager + addEmployee( type : int, fn : String, ln : String, m : char, g : char, en : int, ft : boolean, amount : double) + removeEmployee( index : int) + listAll() + listHourly() + listSalary() + listCommision() + resetWeek() + calculatePayout() :...

  • Java using data structures The objective is to create your own Hash Table class to hold...

    Java using data structures The objective is to create your own Hash Table class to hold a list of employees and their ID numbers. I've provided the TableEntry class which will be each data object in the hash table. The list of employees will be provided as a .txt file and must be read with the code. please create a .txt file called Employees.txt with the info provided so that the java code can read it in. Employees.txt: (No WhiteSpace...

  • JAVA HELP (ARRAYS) Assignment Create a class named Module4 containing the following data members and methods...

    JAVA HELP (ARRAYS) Assignment Create a class named Module4 containing the following data members and methods (note that all data members and methods are for objects unless specified as being for the entire class) 1) Data members: none 2) Methods a. A method named displayContents that accepts an array of type int and prints their values to the b. A method named cemoveNegatives that accepts an array of type int, copies all its non-negative the new array should be the...

  • JAVA Using the data provided in the attachment, create a program that will display a child's...

    JAVA Using the data provided in the attachment, create a program that will display a child's predicted adult height. This program will need to create an array of objects to search. This program needs to validate the input for valid range and input values. If invalid data is given, the program needs to indicate that data is invalid and suggest appropriate values/ranges. However, you do not need to validate alphabetic data given for numeric input. 1. The program will need...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT