Design a Java Application project for maintaining Employee Information in a company. Follow the instructions below for further details.
(i) Create a class named EmpDetails.
(ii) Declare variables emp_name as String (To hold employee name), emp_id as Integer (To hold employee id), emp_desig as String (To hold designation of the employee) and basic as Integer (To hold the basic salary of the employee).
(iii) Define and declare a method named read_data( ) that reads the name, id, designation and basic salary of the employees from the user.
(iv) Define and declare a method named salary( ) that calculates the gross salary of all the employees from the basic salary. (Gross Salary = Basic Salary – EPF – Socso where EPF is 11% of Basic Salary and Socso is 1% of Basic Salary)
(v) Define and declare a method named show_data( ) that prints the name, id, designation and gross salary of all the employees to the user.
(vi) The program should enable the user to have the database of atleast 25 employees.
(vii) Create another class named Employee and declare the main( ) method in it.
(viii) Create object for EmpDetails in the main( ) method and use the same to access the methods.

Dani AI

Generated

A short, practical plan for (and a reminder of 's good advice to take the task one small step at a time).

Break the job into three concrete steps: input, calculation, output. Use a single Scanner passed around (avoid mixing nextInt() and nextLine() which commonly drops input). Store 25+ employee records in an array or ArrayList, keep salary math in a dedicated method (use double for intermediate calculations), and print a formatted table. Validate numeric input and avoid closing the Scanner until all reads finish. For money-level precision consider BigDecimal if exact cents are required; for classroom work double is usually fine.

A minimal, working Java sketch follows. It shows one record class with readData, a calculation method, and a main that collects 25 employees and prints results.

import java.util.Scanner;

class EmpDetails {
  String name;
  int id;
  String desig;
  int basic;
  double gross;

  void readData(Scanner sc) {
    System.out.print("Name: ");
    name = sc.nextLine();
    System.out.print("ID: ");
    id = Integer.parseInt(sc.nextLine());
    System.out.print("Designation: ");
    desig = sc.nextLine();
    System.out.print("Basic salary: ");
    basic = Integer.parseInt(sc.nextLine());
    calcSalary();
  }

  void calcSalary() {
    double epf = basic * 0.11;
    double socso = basic * 0.01;
    gross = basic - epf - socso;
  }

  void showData() {
    System.out.printf("%-20s %-6d %-15s %8.2f%n", name, id, desig, gross);
  }
}

public class Employee {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = 25;
    EmpDetails[] emps = new EmpDetails[n];
    for (int i = 0; i < n; i++) {
      System.out.println("Enter data for employee " + (i+1));
      emps[i] = new EmpDetails();
      emps[i].readData(sc);
    }
    System.out.println("\nName                 ID     Designation     Gross");
    for (EmpDetails e : emps) e.showData();
    sc.close();
  }
}

If compilation or runtime errors appear, the usual next step (per ) is to isolate one step, run it, and post the exact code plus the exact error message so the cause can be pinpointed.

Recommended Answers

All 5 Replies

Do you have questions about the assignment? Post them.
Also post your code and the full text of the error messages.

ill think this is the question...ive not done yet this coding bcoz its make my head dizzy about this question...thats why i need someone help to solve it or show some example for me....i hope u can help me with this question....ty

The forum has lots of code examples. Take a look around.
When you have some problems with your code, post the code and your questions.

The best way to solve a hard problem is to do it one small step at a time.

thx for ur help...which part i need to click to check the example in this blog?? a bit confusing...

Do a Search or ask Google.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.