0% found this document useful (0 votes)
44 views1 page

Employee Java

The document contains a Java program that defines an 'Employee1' class with attributes for employee ID, name, and salary. It includes methods to raise the salary by a given percentage and to display employee details. The 'Employee' class demonstrates creating an instance of 'Employee1', displaying initial details, applying a salary increase, and displaying updated details.

Uploaded by

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

Employee Java

The document contains a Java program that defines an 'Employee1' class with attributes for employee ID, name, and salary. It includes methods to raise the salary by a given percentage and to display employee details. The 'Employee' class demonstrates creating an instance of 'Employee1', displaying initial details, applying a salary increase, and displaying updated details.

Uploaded by

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

import java.util.

Scanner;
class Employee1{
private int id;
private String name;
private double salary;

public Employee1(int id,String name,double salary){


this.id=id;
this.name=name;
this.salary=salary;
}

public void raiseSalary(double percent){


double increaseAmount =salary*(percent/100);
salary+=increaseAmount;
System.out.println(name+"s salary has been incresed by"+percent+"\n%New salary:$"+salary
);
}
public void displayDetails(){
System.out.println("Employee ID:"+id);
System.out.println("Employee Name:"+name);
System.out.println("Employee Salary:"+salary);
}
}
public class Employee{
public static void main(String[]args){
Employee1 employee1 = new Employee1(101,"John Doe",50000);
System.out.println("Initial Employee Details:");
employee1.displayDetails();
employee1.raiseSalary(10);
System.out.println("\nEmployee Details after Salary Increse:");
employee1.displayDetails();
}
}

You might also like