Question

In: Computer Science

A java program with classes and methods to manage employment. Program should be able to store/add...

A java program with classes and methods to manage employment. Program should be able to store/add employees, calculate payroll, display or schedule shifts.

All classes should have at least a null constructor and copy constructor. Other constructors are up to your discretion. Include all necessary accessors and modifiers.

To test the classes, create a container class with simply a main() method. The container class will have attributes that are class objects of each of the classes you create. The main() method will create the class objects, perform duties and produce appropriate output.

Solutions

Expert Solution

import java.util.Scanner;

class Employee

{

    int age;

    String name, address, gender;

    Scanner get = new Scanner(System.in);

    Employee()

    {

        System.out.println("Enter Name of the Employee:");

        name = get.nextLine();

        System.out.println("Enter Gender of the Employee:");

        gender = get.nextLine();

        System.out.println("Enter Address of the Employee:");

        address = get.nextLine();

        System.out.println("Enter Age:");

        age = get.nextInt();

    }

    void display()

    {

        System.out.println("Employee Name: "+name);

        System.out.println("Age: "+age);

        System.out.println("Gender: "+gender);

        System.out.println("Address: "+address);

    }

}

class fullTimeEmployees extends Employee

{

    float salary;

    int des;

    fullTimeEmployee()

    {

        System.out.println("Enter Designation:");

        des = get.nextInt();

        System.out.println("Enter Salary:");

        salary = get.nextFloat();

    }

    void display()

    {

        System.out.println("Full Time Employee Details"+"\n");

        super.display();

        System.out.println("Salary: "+salary);

        System.out.println("Designation: "+des);

    }

}

class partTimeEmployees extends Employee

{

    int workinghrs, rate;

    partTimeEmployees()

    {

        System.out.println("Enter Number of Working Hours:");

        workinghrs = get.nextInt();

    }

    void calculatepay()

    {

        rate = 8 * workinghrs;

    }

    void display()

    {

        System.out.println("Part Time Employee Details"+"\n");

        super.display();

        System.out.println("Number of Working Hours: "+workinghrs);

        System.out.println("Salary for "+workinghrs+" working hours is: $"+rate);

    }

}

class Employees

{

    public static void main(String args[])

    {

        System.out.println("Enter Full Time Employee Details"+"\n");

        fullTimeEmployees ob1 = new fullTimeEmployees();

        partTimeEmployees ob = new partTimeEmployees();

        System.out.println(Enter Part Time Employee Details"+"\n");

        ob1.display();

        ob.calculatepay();

        ob.display();

    }

}


Related Solutions

Write a program in java which is in main and uses no classes, methods, loops or...
Write a program in java which is in main and uses no classes, methods, loops or if statements Ask the user to enter their first name Ask the user to enter their last name Print their initials followed by periods (ie. Clark Kent = C. K.) Print the number of letters in their last name
JAVA Add static methods largest and smallest to the Measurable interface. The methods should return the...
JAVA Add static methods largest and smallest to the Measurable interface. The methods should return the object with the largest or smallest measure from an array of Measurable objects.
Java GPA calculator. Apply GUI, methods, exception handling, classes, objects, inheritance etc. The program should prompt...
Java GPA calculator. Apply GUI, methods, exception handling, classes, objects, inheritance etc. The program should prompt user for input. When done it should give an option to compute another GPA or exit.
This program is written in Java and should be modularized in methods in one class. This...
This program is written in Java and should be modularized in methods in one class. This program will calculate the Gross Earnings, FICA tax (Medicare and Social Security taxes), Federal Tax Withheld, and Net Amount of the payroll check for each employee of a company. The output must contain numbers with 2 decimal places. The user input must be validated – if incorrect data is entered, send an error message to the user. INPUT The application must be able to...
The purpose of the program is for the user to be able to manage a grocery...
The purpose of the program is for the user to be able to manage a grocery list. The user should be presented with a menu to either add and item or quit. The menu input should be case insensitive (e.g. 'a' and 'A' should both work to add). At the top of the starting code, you will notice the function prototypes for two functions: char chooseMenu() this function should present the menu and return what the user inputs (as a...
Complete the java program. /* Note: Do not add any additional methods, attributes. Do not modify...
Complete the java program. /* Note: Do not add any additional methods, attributes. Do not modify the given part of the program. Run your program against the provided Homework2Driver.java for requirements. */ /* Hint: This Queue implementation will always dequeue from the first element of the array i.e, elements[0]. Therefore, remember to shift all elements toward front of the queue after each dequeue. */ public class QueueArray<T> { public static int CAPACITY = 100; private final T[] elements; private int...
The program should be able to do the following: In Java accepts one command line parameter....
The program should be able to do the following: In Java accepts one command line parameter. The parameter specifies the path to a text file containing the integers to be sorted. The structure of the file is as follows: There will be multiple lines in the file (number of lines unknown). Each line will contain multiple integers, separated by a single whitespace. reads the integers from the text file in part a into an array of integers. sort the integers...
In Java: "The program should be able to read a two-digit number d from the standard...
In Java: "The program should be able to read a two-digit number d from the standard input using Scanner class and outputs the second digit followed by a string literal "<-->" followed by the first digit. Run your program and make sure it prints 2<-->5 when d=52"
Program in Java Create a stack class to store integers and implement following methods: 1- void...
Program in Java Create a stack class to store integers and implement following methods: 1- void push(int num): This method will push an integer to the top of the stack. 2- int pop(): This method will return the value stored in the top of the stack. If the stack is empty this method will return -1. 3- void display(): This method will display all numbers in the stack from top to bottom (First item displayed will be the top value)....
Program in Java Create a queue class to store integers and implement following methods: 1- void...
Program in Java Create a queue class to store integers and implement following methods: 1- void enqueue(int num): This method will add an integer to the queue (end of the queue). 2- int dequeue(): This method will return the first item in the queue (First In First Out). 3- void display(): This method will display all items in the queue (First item will be displayed first). 4- Boolean isEmpty(): This method will check the queue and if it is empty,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT