-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8.cpp
More file actions
80 lines (61 loc) · 1.64 KB
/
8.cpp
File metadata and controls
80 lines (61 loc) · 1.64 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
@Author: Amritanshu Sikdar
Session: 2018-'19
Repository: https://github.com/amritanshusikdar/CS30PracticalQuestion
*/
// To accept Employee data and display in given format
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<iomanip.h>
struct emp
{
char name[20];
int basic;
};
void line(); // Prototype
void main()
{
clrscr();
int sno;
emp emp;
float da, hra, total, pf, netpay;
fstream file("EMP.TXT", ios::in | ios::out);
// Entering Employee data
for(sno=1; sno<=5; sno++)
{
cout << "Employee " << sno << ":- " << endl;
cout << "Name: ";
gets(emp.name);
cout << "Basic: ";
cin >> emp.basic;
cout << endl;
file.write((char*) &emp, sizeof(emp));
}
// Displaying Employee data
cout << "\t\t\tSALARY REGISTER\n";
line();
cout << "S.No. Name \t Basic\t DA\tHRA\tTotal\tPF\tNetPay" << endl;
line();
file.seekg(0,ios::beg);
sno=1; // Serial Number
while(file.read((char*) &emp, sizeof(emp)))
{
da = emp.basic*0.3;
hra = emp.basic*0.1;
total = emp.basic + da + hra;
pf = (emp.basic + da)*0.1;
netpay = total + pf;
cout << setw(3) << sno << " " << setw(5) << emp.name << '\t' << setw(5) << emp.basic << '\t' << setw(5) << da << '\t' << setw(4) << hra << '\t' << setw(5) << total << '\t' << setw(5) << setprecision(5) << pf << '\t' << setw(5) << setprecision(5) << netpay << endl;
sno++;
}
line();
file.close();
getch();
}
void line()
{
for(int i=0; i<64; i++)
cout << '-';
cout << endl;
}