-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask5.cpp
More file actions
48 lines (37 loc) · 914 Bytes
/
Copy pathtask5.cpp
File metadata and controls
48 lines (37 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
using namespace std;
class Employee {
private:
double salary;
int empID;
public:
string name;
string department;
Employee(string n, string d, int id, double s) {
name = n;
department = d;
empID = id;
salary = s;
}
void setSalary(double s) {
if (s >= 0)
salary = s;
}
double getSalary() {
return salary;
}
void displayDetails() {
cout << "Name: " << name << endl;
cout << "Department: " << department << endl;
cout << "Employee ID: " << empID << endl;
cout << "Salary: ₹" << salary << endl;
}
};
int main() {
Employee e1("Tejo Hasini", "HR", 101, 40000.0);
e1.displayDetails();
e1.setSalary(45000.0);
cout << "\nAfter Salary Update:\n";
e1.displayDetails();
return 0;
}