Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
5 views
java
it is for programig
Uploaded by
sumukhanayak025
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download now
Download
Save java For Later
Download
Save
Save java For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
5 views
java
it is for programig
Uploaded by
sumukhanayak025
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download now
Download
Save java For Later
Carousel Previous
Carousel Next
Save
Save java For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 1
Search
Fullscreen
public class Employee {
private int id;
private String name;
private double salary;
public Employee(int id, String name, double salary) {
this.id = id;
this.name = name;
this.salary = salary;
}
public void raiseSalary(double percent) {
if (percent > 0) {
double raiseAmount = salary * (percent / 100);
salary += raiseAmount;
System.out.println(name + "'s salary raised by " + percent + "%. New
salary: $" + salary);
} else {
System.out.println("Invalid percentage. Salary remains unchanged.");
}
}
public String toString() {
return "Employee ID: " + id + ", Name: " + name + ", Salary: $" + salary;
}
public static void main(String[] args) {
// Creating an Employee object
Employee employee = new Employee(1, "John Doe", 50000.0);
// Displaying employee details
System.out.println("Initial Employee Details:");
System.out.println(employee);
// Raising salary by 10%
employee.raiseSalary(10);
// Displaying updated employee details
System.out.println("\nEmployee Details after Salary Raise:");
System.out.println(employee);
}
}
You might also like
Polymorphism, Relations
PDF
50% (2)
Polymorphism, Relations
46 pages
Exp 3
PDF
No ratings yet
Exp 3
1 page
Lab P3
PDF
No ratings yet
Lab P3
1 page
Program 3
PDF
No ratings yet
Program 3
2 pages
Program 3
PDF
No ratings yet
Program 3
2 pages
Id Firstname Lastname Salary Id Firstname Lastname Salary
PDF
No ratings yet
Id Firstname Lastname Salary Id Firstname Lastname Salary
1 page
program on this keyword
PDF
No ratings yet
program on this keyword
2 pages
Employee Salary Code - PDF
PDF
No ratings yet
Employee Salary Code - PDF
3 pages
Employee
PDF
No ratings yet
Employee
2 pages
Homework #1: Please Refer To The Code in The Appendix (Pages 2 - 6) To Answer The Following Questions
PDF
No ratings yet
Homework #1: Please Refer To The Code in The Appendix (Pages 2 - 6) To Answer The Following Questions
5 pages
PGM 3
PDF
No ratings yet
PGM 3
1 page
op 5
PDF
No ratings yet
op 5
9 pages
Oop 3 Fa20-Be-012
PDF
No ratings yet
Oop 3 Fa20-Be-012
19 pages
Ict 3309
PDF
No ratings yet
Ict 3309
12 pages
List Array Java
PDF
No ratings yet
List Array Java
5 pages
Neelu
PDF
No ratings yet
Neelu
14 pages
PR 4
PDF
No ratings yet
PR 4
4 pages
Example Codes For OOP Practical Model Questions
PDF
No ratings yet
Example Codes For OOP Practical Model Questions
8 pages
Employee
PDF
No ratings yet
Employee
3 pages
Class Employee
PDF
No ratings yet
Class Employee
2 pages
Java_CH3_Exercise
PDF
No ratings yet
Java_CH3_Exercise
6 pages
Lab 7
PDF
No ratings yet
Lab 7
29 pages
Lab Polymorphism
PDF
No ratings yet
Lab Polymorphism
6 pages
Pro192 HW w3 SE17B04
PDF
No ratings yet
Pro192 HW w3 SE17B04
12 pages
Prova Av2
PDF
No ratings yet
Prova Av2
11 pages
Import Public Class Private Double Private Static Double Public Double If
PDF
No ratings yet
Import Public Class Private Double Private Static Double Public Double If
1 page
Assignment - 3
PDF
No ratings yet
Assignment - 3
5 pages
Person
PDF
No ratings yet
Person
3 pages
Java lab
PDF
No ratings yet
Java lab
30 pages
Assignment# 2
PDF
No ratings yet
Assignment# 2
5 pages
2.2 Employee
PDF
No ratings yet
2.2 Employee
1 page
1) Inheritance & Constructor
PDF
No ratings yet
1) Inheritance & Constructor
8 pages
EmplyeeDemo1
PDF
No ratings yet
EmplyeeDemo1
1 page
Create 4 Class Person, Staff, Temporarystaff and A Main Class - .
PDF
No ratings yet
Create 4 Class Person, Staff, Temporarystaff and A Main Class - .
7 pages
javaprogram3
PDF
No ratings yet
javaprogram3
2 pages
04 Task Performance 1prelim Exam - ARG
PDF
No ratings yet
04 Task Performance 1prelim Exam - ARG
4 pages
Abdullah Ayub (002) Oose Lab #2: Eclipse
PDF
No ratings yet
Abdullah Ayub (002) Oose Lab #2: Eclipse
6 pages
aoop skill week-5
PDF
No ratings yet
aoop skill week-5
13 pages
Untitled document-1
PDF
No ratings yet
Untitled document-1
4 pages
4.2
PDF
No ratings yet
4.2
2 pages
Assignment8_AbstractClass_Staff (1)
PDF
No ratings yet
Assignment8_AbstractClass_Staff (1)
4 pages
Employees: Employee
PDF
No ratings yet
Employees: Employee
6 pages
Java Record 5
PDF
No ratings yet
Java Record 5
4 pages
day-1-intro
PDF
No ratings yet
day-1-intro
15 pages
Java
PDF
No ratings yet
Java
5 pages
Example: Now Suppose We Extend Employee Class As Follows
PDF
No ratings yet
Example: Now Suppose We Extend Employee Class As Follows
2 pages
Java Project Report On Employee Management System
PDF
100% (1)
Java Project Report On Employee Management System
16 pages
1011 2
PDF
No ratings yet
1011 2
11 pages
ass3prac2
PDF
No ratings yet
ass3prac2
4 pages
Import Class Private Private Private Double Public
PDF
No ratings yet
Import Class Private Private Private Double Public
2 pages
Untitled Document
PDF
No ratings yet
Untitled Document
3 pages
Employee Oop Example
PDF
No ratings yet
Employee Oop Example
5 pages
OOP Lab Session 4 Q 18
PDF
No ratings yet
OOP Lab Session 4 Q 18
3 pages
Abstraction Program Java
PDF
No ratings yet
Abstraction Program Java
2 pages
Java 4 Nov Ques2
PDF
No ratings yet
Java 4 Nov Ques2
3 pages
CODER
PDF
No ratings yet
CODER
14 pages
Attachment 1
PDF
No ratings yet
Attachment 1
4 pages
Set9
PDF
No ratings yet
Set9
7 pages
Chapter-Seven: Object-Oriented Implementation
PDF
No ratings yet
Chapter-Seven: Object-Oriented Implementation
23 pages
Angular Reactive Forms: Everything you need to know
From Everand
Angular Reactive Forms: Everything you need to know
Abdelfattah Ragab
No ratings yet