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 [Link].*;
class Employee
{
Scanner sc=new Scanner([Link]);
int empid;
String empContactNumber;
String empName;
Double bs,hra,da,Gs;
void enterinfo()
{
[Link]("Enter Employee Information\n");
[Link]("Enter Employee ID");
empid=[Link]();
[Link]();
[Link]("Enter employee name");
empName=[Link]();
[Link]("Enter Contact number");
empContactNumber=[Link]();
[Link]("\n\n");
}
void showinfo()
{
[Link]("Employee ID: "+empid);
[Link]("Employee Name: "+empName);
[Link]("Emp Contact no: "+empContactNumber+"\n");
}
}
public class exp3
{
public static void main(String[] args)
{
Employee emp1=new Employee();
[Link]();
[Link]();
}
}
Output:
Conclusion
Code is successfully implemented.