diff --git a/OOP/Java/Lab/Week5/Employee.java b/OOP/Java/Lab/Week5/Employee.java new file mode 100644 index 0000000..5ad63ae --- /dev/null +++ b/OOP/Java/Lab/Week5/Employee.java @@ -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(); + } +} \ No newline at end of file