EXP 3.java
EXP 3.java
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");
}
}
Output:
Conclusion
Code is successfully implemented.