Skip to content

Commit f43a496

Browse files
committed
Lab sheet 6
Exercise 3
1 parent 7339fb6 commit f43a496

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
2+
//
3+
4+
#include <iostream>
5+
#include "Employee.h"
6+
7+
using namespace std;
8+
9+
int main(int argc , char* argv[])
10+
{
11+
Employee emp1;
12+
int iempno;
13+
char iname[20];
14+
double bsal;
15+
16+
/*cout << "Enter Employee No : " << flush;
17+
cin >> iempno;
18+
cout << "Ente Name : " << flush;
19+
cin >> iname;
20+
cout << "Enter Basic Salary : " << flush;
21+
cin >> bsal;*/
22+
23+
//emp1.assignDetails(iempno, iname , bsal);
24+
25+
//emp1.assignDetails(10, "Wimal", 50000);
26+
27+
emp1.InputDetails();
28+
emp1.setAllowance(5000);
29+
emp1.setOTdetails(100, 100);
30+
emp1.calcSal();
31+
emp1.printPaySlip();
32+
33+
char ch;
34+
cin >> ch;
35+
36+
return 0;
37+
}
38+
39+
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
40+
// Debug program: F5 or Debug > Start Debugging menu
41+
42+
// Tips for Getting Started:
43+
// 1. Use the Solution Explorer window to add/manage files
44+
// 2. Use the Team Explorer window to connect to source control
45+
// 3. Use the Output window to see build output and other messages
46+
// 4. Use the Error List window to view errors
47+
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
48+
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include "Employee.h"
2+
#include <iostream>
3+
#include <cstring>
4+
5+
using namespace std;
6+
7+
void Employee::InputDetails()
8+
{
9+
cout << "Enter Employee No : " << flush;
10+
cin >> empno;
11+
cout << "Ente Name : " << flush;
12+
cin >> name;
13+
cout << "Enter Basic Salary : " << flush;
14+
cin >> basicSal;
15+
}
16+
17+
void Employee::assignDetails(int pempno,const char pname[], double pbasicSal)
18+
{
19+
empno = pempno;
20+
strcpy_s(name, pname);
21+
basicSal = pbasicSal;
22+
}
23+
24+
void Employee::setAllowance(double pallowance)
25+
{
26+
allowance = pallowance;
27+
}
28+
29+
void Employee::setOTdetails(double pOTrate, double phours)
30+
{
31+
OTrate = pOTrate;
32+
hours = phours;
33+
}
34+
35+
void Employee::calcOT()
36+
{
37+
OTsal = OTrate * hours;
38+
}
39+
40+
void Employee::calcSal()
41+
{
42+
calcOT();
43+
salary = OTsal + basicSal + allowance;
44+
}
45+
46+
void Employee::printPaySlip()
47+
{
48+
cout << "-------------------------------------------------" << endl;
49+
cout << "Emp No \t\t : " << empno << endl;
50+
cout << "Name \t\t : " << name << endl;
51+
cout << "Basic Salary \t : " << basicSal << endl;
52+
cout << "Allowance \t : " << allowance << endl;
53+
cout << "OT \t\t : " << OTsal << endl;
54+
cout << "Net Salary \t : " << salary << endl;
55+
cout << "-------------------------------------------------" << endl;
56+
57+
}
58+
59+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
class Employee
3+
{
4+
private:
5+
int empno;
6+
char name[20];
7+
double basicSal;
8+
double allowance;
9+
double salary;
10+
double OTrate;
11+
double hours;
12+
double OTsal;
13+
14+
public:
15+
void assignDetails(int pempno,const char pname[], double pbasicSal);
16+
void setAllowance(double pallowance);
17+
void calcSal();
18+
void printPaySlip();
19+
void setOTdetails(double pOTrate, double phours);
20+
void calcOT();
21+
void InputDetails();
22+
};
23+

0 commit comments

Comments
 (0)