Knowee
Questions
Features
Study Tools

Get a count of number of employees. Get the input details from each employee like name, address, designation ,‘section name’ and ‘department’ till that particular count is reached.In the names of the employees   where the pattern “im” occurs. Replace it by ‘is’.Using static member functions/static variable, assign a unique roll number to each employee.Display all the employee details. Implement the above process using java class and constructors.

Question

Get a count of number of employees. Get the input details from each employee like name, address, designation ,‘section name’ and ‘department’ till that particular count is reached.In the names of the employees   where the pattern “im” occurs. Replace it by ‘is’.Using static member functions/static variable, assign a unique roll number to each employee.Display all the employee details. Implement the above process using java class and constructors.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a simple implementation of your request in Java. This program will create a list of employees, assign a unique roll number to each, and then display their details. It will also replace "im" with "is" in the employee names.

import java.util.*;

class Employee {
    private static int count = 0;
    private String name;
    private String address;
    private String designation;
    private String sectionName;
    private String department;
    private int rollNumber;

    public Employee(String name, String address, String designation, String sectionName, String department) {
        this.name = name.replace("im", "is");
        this.address = address;
        this.designation = designation;
        this.sectionName = sectionName;
        this.department = department;
        this.rollNumber = ++count;
    }

    public static int getCount() {
        return count;
    }

    public void displayDetails() {
        System.out.println("Roll Number: " + rollNumber);
        System.out.println("Name: " + name);
        System.out.println("Address: " + address);
        System.out.println("Designation: " + designation);
        System.out.println("Section Name: " + sectionName);
        System.out.println("Department: " + department);
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter the number of employees: ");
        int numEmployees = scanner.nextInt();
        scanner.nextLine();

        List<Employee> employees = new ArrayList<>();
        for (int i = 0; i < numEmployees; i++) {
            System.out.println("Enter details for employee " + (i + 1));
            System.out.println("Enter name: ");
            String name = scanner.nextLine();
            System.out.println("Enter address: ");
            String address = scanner.nextLine();
            System.out.println("Enter designation: ");
            String designation = scanner.nextLine();
            System.out.println("Enter section name: ");
            String sectionName = scanner.nextLine();
            System.out.println("Enter department: ");
            String department = scanner.nextLine();

            employees.add(new Employee(name, address, designation, sectionName, department));
        }

        for (Employee employee : employees) {
            employee.displayDetails();
        }
    }
}

This program first asks for the number of employees. It then asks for the details of each employee, creates an Employee object with those details, and adds it to a list. Finally, it displays the details of each employee. The Employee class has a static variable count that is incremented each time an Employee is created, providing a unique roll number for each employee. The replace method is used to replace "im" with "is" in the employee names.

This problem has been solved

Similar Questions

Get a count of number of students. Get the input details from each student like 'name', 'address',  ‘class number’ and ‘department’ till that particular count is reached.In the names of the student   where the pattern “in” occurs. Replace it by ‘$$’.Using static member functions/static variable, assign a unique roll number to each student.Display all the student details. Implement the above process using java class and constructors.Ex: Stalin (pattern “in”)

Design a class named Person and its two subclasses named Student and Employee.  Make Faculty and Staff subclasses of Employee. A person has a name,  address, phone_number, and e-mail address. A student has a status (freshman, sophomore, junior, or senior).  An employee  has an office, salary. A faculty member has office_hours and a rank. A staff member has a title. Override the toString() method in each of these classes to display their details. Write a Java application and subsequent pseudocode to implement/simulate the same.Input :First line must read the Type of the Object(Person(P)/Employee(E)/Faculty(F)/Student(S)/Staff(T).Second line onwards read details such as name, address, phoneNo, Email and soonOutput :Print ClassName : Name, Address, PhonNo, Email, and rest of the datamembers of that class. For Example :if Type = P, then print Person : Name, Address, PhoneNo, Emailif Type = S, then print Student : Name, Address, PhoneNo, Email, Statusif Type = E, then print Employee : Name, Address, PhoneNo, Email, Office, Salaryif Type = T, then print Staff : Name, Address, PhoneNo, Email, Office, Salary, Titleif Type = F, then print Faculty : Name, Address, PhoneNo, Email, Office, Salary, Office_Hrs, RankNote :The Status for Student is freshman, sophomore, junior, or senior.Overide only toString() method in all the Classes.

[25 points] Write a Java class named Employee such that the class contains threeattributes empName, salary, and departmentName. You should be able to createobjects of this class by supplying values to any one, two, or all three of the attributes. Ifno value is supplied during the object creation, the attributes should be initialized withsome default values. You are expected to use 'this' keyword to achieve the result. Discussthe ways in which you can change or reset the attribute values of the objects created.Write appropriate mutator methods that store values in these fields and accessormethods that return the values in these fields. Once you have written the class, write aseparate program that creates three Employee objects to hold the following data:Employee Name Department Salary---------------------------------------------------------------------Susan Meyers Accounting 5000.00Mark Jones IT 8375.00Joy Rogers Manufacturing 6380.00---------------------------------------------------------------------The program should store this data in the three objects and then display the data for eachemployee on the screen

21. Write a Java program that creates a class hierarchy for employees of a company. The base class should be Employee, with subclasses Manager, Developer, and Programmer. Each subclass should have properties such as name, address, salary, and job title. Implement methods for calculating bonuses, generating performance reports, and managing projects

Review the class Employee example provided in the tutorial.What code segment could be added as a method to return the number of employees managed, if this was kept track in a variable called numManaged?a.)public int getNumManaged(){ return numManaged;}b.)public void getNumManaged(){ return numManaged;}c.)public int getNumManaged(){ return employeesManaged;}d.)public void getNumManaged(int numManaged){ return numManaged;}

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.