0% found this document useful (0 votes)
2 views

EXP 3.java

The document outlines an experiment to create a Java program defining an 'Employee' class with attributes for employee details and salary calculation. It includes methods to enter and display employee information, as well as the calculation of gross salary based on basic salary, HRA, and DA. The implementation of the code was successful.

Uploaded by

Shreya Ranjane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

EXP 3.java

The document outlines an experiment to create a Java program defining an 'Employee' class with attributes for employee details and salary calculation. It includes methods to enter and display employee information, as well as the calculation of gross salary based on basic salary, HRA, and DA. The implementation of the code was successful.

Uploaded by

Shreya Ranjane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment No.

Roll No: 124A8092

Aim: Program on class and objects.

WAP to define a class employee with data members as bs,hra,da, empid, age , name . Calculate gross
salary. GS=bs+hra+da and hr is 10% of bs, da is 20 % of bs.
Theory:

Code:
import java.util.*;
class Employee
{
Scanner sc=new Scanner(System.in);
int empid;
String empContactNumber;
String empName;
Double bs,hra,da,Gs;

void enterinfo()
{
System.out.println("Enter Employee Information\n");
System.out.println("Enter Employee ID");
empid=sc.nextInt();
sc.nextLine();
System.out.println("Enter employee name");
empName=sc.nextLine();
System.out.println("Enter Contact number");
empContactNumber=sc.nextLine();
System.out.println("\n\n");
}

void showinfo()
{
System.out.println("Employee ID: "+empid);
System.out.println("Employee Name: "+empName);
System.out.println("Emp Contact no: "+empContactNumber+"\n");
}
}

public class exp3


{
public static void main(String[] args)
{
Employee emp1=new Employee();
emp1.enterinfo();
emp1.showinfo();
}
}

Output:
Conclusion
Code is successfully implemented.

You might also like