Add OOP/Java/Lab/Week5/Employee.java
This commit is contained in:
parent
bb4743a9ed
commit
3957b1c51b
46
OOP/Java/Lab/Week5/Employee.java
Normal file
46
OOP/Java/Lab/Week5/Employee.java
Normal file
@ -0,0 +1,46 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Employee {
|
||||
String name;
|
||||
String city;
|
||||
double salary;
|
||||
double da;
|
||||
double hra;
|
||||
double ctc;
|
||||
|
||||
public void getData() {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.print("Enter Employee Name: ");
|
||||
name = sc.nextLine();
|
||||
System.out.print("Enter city: ");
|
||||
city = sc.nextLine();
|
||||
System.out.print("Enter salary: ");
|
||||
salary = sc.nextDouble();
|
||||
System.out.print("Enter dearness allowance (DA%): ");
|
||||
da = sc.nextDouble();
|
||||
System.out.print("Enter house rent allowance (HRA%): ");
|
||||
hra = sc.nextDouble();
|
||||
sc.close();
|
||||
}
|
||||
|
||||
public double calculateCTC() {
|
||||
ctc = salary + (salary * (da+hra) / 100) +;
|
||||
return ctc;
|
||||
}
|
||||
|
||||
public void display() {
|
||||
System.out.println("Employee Name: " + name);
|
||||
System.out.println("Employee City: " + city);
|
||||
System.out.println("Employee Salary: " + salary);
|
||||
System.out.println("Employee DA%: " + da);
|
||||
System.out.println("Employee HRA%: " + hra);
|
||||
System.out.println("Employee CTC (Total Cost to Company): " + ctc);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Employee emp = new Employee();
|
||||
emp.getData();
|
||||
emp.calculateCTC();
|
||||
emp.display();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user