Algorithm: A1 Prepare payroll report. Declare numeric overtime pay , regular pay
ID: 3633091 • Letter: A
Question
Algorithm:
A1 Prepare payroll report.
Declare numeric overtime pay , regular pay, gross pay, taxwitheld, net pay, hourly pay rate, hours worked, net pay total, linesused_counter, page_counter, line_limit.
Declare character employee name, employee number, out-of-range- flag.
Do U1 Get payroll record.
If there is a correct record, then
Do B2 Set totals to zero.
Do B3 print pages.
Do B4 Print line of totals.
Else
Print ‘THERE ARE NO INPUT RECORDS.’.
End if.
Stop.
B2 Set totals to zero.
Set overtime pay total to zero.
Set regular pay total to zero.
Set gross pay total to zero.
Set tax withheld total to zero.
Set net pay total to zero.
B3 Print pages.
Set line limit to 50.
Set page counter to zero.
Loop while there is a record.
Do C1 Pint headings
Do C2 Finish page.
B4 Print line of totals.
Print ‘TOTALS’. Regular pay total, overtime pay, gross pay total, tax withheld total, net pay total
C1 Print headings.
Page counter= page + 1
Print ‘PAGE’, page counter at top of page
Print ‘YUMMY GROCERY SUPPLY, INC.
Print ’PAYROLL REPORT’ after double spacing.
Print column headings after double spacing.
Set lines-used counter to 6.
C2 Finish page.
Loop while lines-used counter is not greater than limit and while there is a record.
DO D4 Check input data.
If out-of range flag is ‘NO’, then
DO D2 Compute net pay.
DO D1 Print line of report.
DO D3 Accumulate totals.
End if.
DO U1 Get payroll record.
End loop
D1 Print line of report.
Print line of report: employee number, employee name, hourly
rate, hours worked, regular pay, overtime pay, gross pay, tax
withheld, net pay.
Lines-used counter = lines- used counter + 1.
D2 Compute net pay.
DO D1 Compute gross pay.
DO D2 Compute tax withheld.
Net pay = gross pay – tax withheld.
D3 Accumulate totals.
Regular pay total = regular pay total = regular pay total + regular
pay.
Overtime pay total = overtime pay totals + overtime pay.
Gross pay total = gross pay total + gross pay.
Tax withheld total = Tax withheld total + tax withheld.
Net pay total = Net pay total + net pay.
D4 Check input data.
Set out-of-range flag to ‘NO’.
If hours worked > 50, then
Print ‘HOURS WORKED IS GREATER THAN 50 FOR
EMPLOYEE NUMBER,’ employee number.
Lines-used counter = lines- used counter + 1.
Set out – of –range flag to ‘YES’.
End if.
If hourly pay rate>35.00, then
Print ‘HOURLY PAY RATE IS GREATER THAN $35.00
FOR EMPLOYEE NUMBER’, employee number.
Lines-used counter = lines-used counter + 1.
Set out – of –range flag to ‘YES’.
End – if.
E1 Compute gross pay.
If hours worked > 40, then
Regular pay = hourly pay rate*40.
Overtime pay =(hours worked – 40)*(1.5*hourly pay
rate).
Gross pay = regular pay + overtime pay.
Else
Regular pay = hours worked*hourly pay rate.
Set overtime pay to zero.
Set gross pay to regular pay.
End if.
E2 Compute tax withheld.
Tax withheld = gross pay*0.15.
U1 Get payroll record.
Read payroll record: employee number, employee
name, hourly pay rate, hours worked.
end algorithm.
The code below that i tried to run on unix but does not implement all the variables esp lines-used_counter, page_counter, line_limit :
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
int main()
{
//varaiable declaraions and
//initialization
char empid[10];
double payRate=0;
double hours=0;
double regularPay=0;
double overTime=0;
double grossPay=0;
double tax=0;
double totalTax=0;
double totalRegPay=0;
double totalOverPay=0;
double netPay;
double totalNetpay=0;
char name[20];
//create file stream object
fstream fin;
//open file in read mode
fin.open("Emp.txt",ios::in);
// print if file doesnot exist
if(!fin)
{
cout<<"File couldnot be opened"<<endl;
system("pause");
}
//Heading
cout<<" YUMMY GROCERY SUPPLY ,INC ";
cout<<" PAYROLL REPORT ";
cout<<"EMPLOYEE HOURLY HOURS REGULAR OVERTIME"<<endl;
cout<<"NUMBER EMPLOYEE NAME RATE "
"WORKED"<<" PAY PAY Tax Netpay "<<endl;
//read file data from Emp.txt file
while(fin>>empid>>name>>payRate>>hours)
{
//output to console
cout<<left<<setw(14)<<empid<<setw(15)<<name<<setw(8)<<payRate<<setw(8)<<hours;
//if hours > 40
if(hours>=40)
{
regularPay=payRate*40;
overTime=(hours-40)*(1.5*payRate);
grossPay=regularPay+overTime;
}
else
{
regularPay=payRate*40;
grossPay=regularPay;
}
//tax calculation
tax=grossPay*0.15;
//net apy calculation
netPay=grossPay-tax;
//output to console
cout<<left<<setprecision(5)<<setw(6)<<regularPay<<setw(8)<<overTime<<setw(10)<<tax<<setw(10)<<netPay<<endl;
//calculate total regular pay
//and over time pay
totalRegPay+=regularPay;
totalOverPay+=overTime;
totalNetpay+=netPay;
//clear buffer
cin.clear();
}
//print on console
cout<<" Totals "<<endl;
cout<<"Total Regular Pay "<<totalRegPay<<endl;
cout<<"Total over Time Pay "<<totalOverPay<<endl;
cout<<"Total Netpay "<<totalNetpay<<endl;
system("pause");
return 0;
}
sample payroll record for six employees i need to make for 50 emplyees:
should appear like this format:should print pages of report ex.1 2 3 4 5.........etc
Explanation / Answer
useful link: http://en.wikipedia.org/wiki/Dynamic_programming
The Code For C++ Payroll Records Based System Are Given below
#include
#include
#include
#include //graphics functions
#include
#include
#include //for file handling
#include
struct date_rec //record to get data
{
int dd;
int mm;
int yyyy;
}current_date;
//this class defines data related to monthly pay file
class payfile //base class
{
private:
int emp_num;
char emp_name[25];
char emp_designation[20];
int days_worked,dw;
float basic_pay;
float DA;
float HRA;
float CCA;
float con_veyance;
float gross_pay;
float PF;
float income_tax;
float other_deductions;
float net_pay;
public:
payfile() //no arguments constructor
{
days_worked=0;
basic_pay=DA=HRA=CCA=con_veyance=gross_pay=0.0;
PF=income_tax=other_deductions=net_pay=0.0;
}
void get_pay(); //this function reads the private members of payfile
void update_pay_file();/*this function calls get_pay() and generates
monthly pay file on disk*/
void reports(); /*this function reads the monthly pay file
from disk and generates salary statements*/
/*when a new employee is registered,this function writes its record using
payfile()constructor on disk to make a entry in monthly payfile*/
void add_pay_object(int code,char name[25],char desig[10],float basic);
/*when an employee leaves the company,this function deletes
the entry from monthly pay file*/
void del_pay_object(int code);
/*this function modifies designation of an employee in monthly pay file*/
void modify_pay_object(int code,char desig[20]);
/*this function modifies the basic in pay file*/
void modify_basic(int code,float basic);
}pay;
void payfile::modify_basic(int code,float basic)
{
fstream file;
file.open("payfile.dat",ios::in|ios::out);//opening file
file.seekg(0,ios::beg);//set pointer to the begining
file.read((char*)&pay,sizeof(pay));//read first record
int n=file.tellg();
while(!file.eof())
{
if(code==pay.emp_num)
{
pay.basic_pay=basic;
pay.gross_pay=pay.basic_pay+pay.DA+pay.HRA+pay.CCA+pay.con_veyance;
pay.net_pay=pay.gross_pay-(pay.PF+pay.income_tax+pay.other_deductions);
file.seekg(n-sizeof(pay));
file.write((char*)&pay,sizeof(pay));
file.flush();
file.seekg(0,ios::end);
}
file.read((char*)&pay,sizeof(pay));
n=file.tellg();
}
file.close();
}
void payfile::add_pay_object(int code,char name[25],char desig[20],
float basic)
{
fstream outfile;
pay.emp_num=code;
pay.basic_pay=basic;
strcpy(pay.emp_name,name);
strcpy(pay.emp_designation,desig);
outfile.open("payfile.dat",ios::app);//open fees file in append mode
outfile.write((char*)&pay,sizeof(pay));//make entry in fees file
outfile.flush();
outfile.close();//close fees file
}
void payfile::del_pay_object(int code)
{
fstream outfile,infile;
outfile.open("tempfile.dat",ios::app); //open temporary file
infile.open("payfile.dat",ios::in);//open pay file for reading
infile.seekg(0,ios::beg);//set file pointer to the begining of the file
infile.read((char*)&pay,sizeof(pay));//read the first record
while(!infile.eof())
{
if(pay.emp_num!=code)//if this record is not to be deleted
//write in the temporary
outfile.write((char*)&pay,sizeof(pay));
infile.read((char*)&pay,sizeof(pay));//read next record
}
infile.close();//close pay file
outfile.close();//close temporary file
remove("payfile.dat");//delete old monthly pay file
rename("tempfile.dat","payfile.dat");//temporary file becomes new pay file
}
void payfile::modify_pay_object(int code,char desig[20])
{
fstream file;
file.open("payfile.dat",ios::in|ios::out);//open file for reading/writing
file.seekg(0,ios::beg);//set file pointer to the begining of the file
file.read((char*)&pay,sizeof(pay));//read first record
int n=file.tellg();//tell where we are
while(!file.eof())
{
if(code==pay.emp_num) //record found
{
strcpy(pay.emp_designation,desig);
file.seekg(n-sizeof(pay)); //set fili pointer to the record to be changed
file.write((char*)&pay,sizeof(pay)); //update record
file.flush();
file.seekg(0,ios::end);/*if record found set file pointer to end
of file to stop further searching*/
}
file.read((char*)&pay,sizeof(pay)); //if record not found read next record
n=file.tellg();//tell where we are
}
file.close();
}
void payfile::get_pay()//this function reads the private members of payfile
{
char ch,month[9];
int mon;
cout< <" ENTER MONTH ( 1 to 12 ) --------->";
cin>>mon;
switch(mon)
{ //get month name
case 1 : strcpy(month,"JANUARY");
break;
case 2 : strcpy(month,"FEBRUARY");
break;
case 3 : strcpy(month,"MARCH");
break;
case 4 : strcpy(month,"APRIL");
break;
case 5 : strcpy(month,"MAY");
break;
case 6 : strcpy(month,"JUNE");
break;
case 7 : strcpy(month,"JULY");
break;
case 8 : strcpy(month,"AUGUST");
break;
case 9 : strcpy(month,"SEPTEMBER");
break;
case 10 :strcpy(month,"OCTOBER");
break;
case 11 :strcpy(month,"NOVEMBER");
break;
case 12 :strcpy(month,"DECEMBER");
break;
}
int n;
if(mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12)
{
n=31;
}
else if(mon==2)
{
n=28;
}
else
{
n=30;
}
cout< <" ENTER THE NO.OF DAYS WORKED----------->";
cin>>days_worked;
if(days_worked<23)
{
dw=23-days_worked;
days_worked=n-dw;
}
else
{
days_worked=n;
dw=0;
}
cout< <" =============================================";
cout<<" In the month of "< cout<<" There are "< cout<<" THE BASIC PAY FOR THE MONTH IS "<<(basic_pay/n)*days_worked;
cout<<" THE DEARNESS ALLOWENCE IS (35% of basic) --------->";
DA=(0.35*(basic_pay/n))*days_worked;
cout< cout<<" THE HOUSE RENT ALLOWENCE IS (@ Rs.600/-pm)------->";
HRA=600;
cout< cout<<" THE CCA IS (2% of basic) ------------------------>";
CCA=(0.02*(basic_pay/n))*days_worked;
cout< cout<<" THE CONVEYENCE ALLOWENCE IS (1% of basic)-------->";
con_veyance=(0.01*(basic_pay/n))*days_worked;
cout< gross_pay=((basic_pay/n)*days_worked)+DA+HRA+CCA+con_veyance;
cout<<" PF AMOUNT------------------------------>";
PF=gross_pay*0.08;
cout< if(gross_pay>8000)
{
cout< <" THE INCOME TAX------------------>";
income_tax=(gross_pay-PF)*.1;
cout< }
else
{
income_tax=0;
cout< }
cout<<" OTHER DEDUCTIONS---------------->";
cin>>other_deductions;
net_pay=gross_pay-(PF+income_tax+other_deductions);
gotoxy(22,24);
cout< <"PRESS ANY KEY TO CONTINUE";
getch();
clrscr();
}
void payfile::update_pay_file()
{
fstream file;
file.open("payfile.dat",ios::in|ios::out);//open pay file in I/O mode
file.seekg(0,ios::beg);//set file pointer to the begining of the file
file.read((char*)&pay,sizeof(pay)); //read the first record
int n=file.tellg(); //find where file pointer is
while(!file.eof())
{
clrscr();
cout<<" ENTER DATA FOR EMPLOYEE NO.--------->"< pay.get_pay(); //get pay data
file.seekg(n-sizeof(pay)); //set file pointer to the correct position
file.write((char*)&pay,sizeof(pay));//write pay data in the file
file.flush();
file.seekg(n);//set file pointer to next record
file.read((char*)&pay,sizeof(pay));//read next record
n=file.tellg();//find position of file pointer
}
file.close();//close monthly pay file
}
//this class defines the data and member functionsrelated to employee file
class employee:public payfile //derived class
{
private:
int employee_num;
char employee_name[25];
char employee_address[35];
date_rec date_joining;
date_rec date_birth;
char desig_nation[20];
float basic_salary;
public:
char ch;
int get_rec_no();//this function generates record no.automatically
void get_data(); //this function get a record from the operator
void show_data();//this function displays data
void add_object();//this function writes a record on the disk
void show_object();//this function reads a record
//from the disk and calls show_data()
void del_object();/*this function deletes a record from the employee
file and calls a member function of base class to
update entries in monthly pay file*/
void modify_object();//this function changes information on disk
void search_object();//this function searches information on
//the basis of a given field
}emp; //object list
//this function generates record no. automatically
int employee::get_rec_no()
{
int found=0;
int recno,temp_recno;
struct node //structure to make an index of the record nos
{
int rec_no;
node *link;//pointer to next node
};
node *start,*ptr,*ptr1,*ptr2;//pointers to node
fstream infile;
infile.open("employee.dat",ios::in);//open file in input mode
infile.seekg(0,ios::end);//set file pointer to the begining of the file
int n=infile.tellg();//get no. of bytes in the file
infile.close();//close file
if(n==0)//if file is empty
recno=1;
else
{//get all record nos. in a linked list
infile.open("employee.dat",ios::in);//open file for reading
start=ptr=new node;//get new node from operating system
infile.seekg(0,ios::beg);//set file pointer to the begining of the file
infile.read((char*)&emp,sizeof(emp));//read first record
while(!infile.eof())
{
ptr->rec_no=employee_num;//save record no.in the index
ptr->link=new node;//get new node for next record
ptr=ptr->link;
infile.read((char*)&emp,sizeof(emp));//read next record
}
ptr->link=NULL;//end of list
//sort record nos.
ptr1=start;//set pointer to the start of the index
while(ptr1->link!=NULL)
{
ptr2=ptr1->link;//set second pointer
while(ptr2!=NULL)
{
if(ptr2->rec_norec_no)
{
temp_recno=ptr2->rec_no;//exchange values
ptr2->rec_no=ptr1->rec_no;
ptr1->rec_no=temp_recno;
}
ptr2=ptr2->link;//next node
}
ptr2=ptr1->link;
ptr1=ptr2;//next pass
}
//generate record no.
ptr1=start;
while(ptr1!=NULL&&found!=1)
{
ptr2=ptr1;
ptr1=ptr1->link;
if((ptr2->rec_no)+1!=ptr1->rec_no)
{
recno=(ptr2->rec_no)+1;
found=1;
}
}
if(found!=1)
recno=(ptr2->rec_no)+1;
//destroy the index
ptr=start;
while(start!=NULL)
{
start=start->link;
delete ptr;//delete index to save memory
}
}
return recno;//return the calculated record no.
}
//this function reads data
void employee::get_data()
{
clrscr();
employee_num=get_rec_no();//automatic generation of empship no.
cout< <" ENTER THE NAME-------------------------->";
gets(employee_name);
cout< <" ENTER THE ADDRESS----------------------->";
gets(employee_address);
cout< <" ENTER THE DATE OF JOINING<>------->";
cin>>date_joining.dd>>ch>>date_joining.mm>>ch>>date_joining.yyyy;
cout< <" ENTER THE DATE OF BIRTH <>-------->";
cin>>date_birth.dd>>ch>>date_birth.mm>>ch>>date_birth.yyyy;
cout< <" ENTER DESIGNATION----------------------->";
gets(desig_nation);
cout< <" ENTER THE BASIC SALARY------------------>";
cin>>basic_salary;
}
//this function displays data
void employee::show_data()
{
clrscr();
cout< <" EMPLOYEE NO.--------------------->"< cout<<" EMPLOYEE's NAME------------------>"< cout<<" DATE OF JOINING------------------>"< <<"-"< <<"-"< cout<<" EMPLOYEE's ADDRESS--------------->"< cout<<" DATE OF BIRTH-------------------->"< <<"-"< <<"-"< cout<<" DESIGNATION---------------------->"< cout<<" BASIC SALARY--------------------->RS."< < < < < < gotoxy(22,24);
cout<<"PRESS ANY KEY TO CONTINUE";
getch();
}
//this function writes a record into a file
void employee::add_object()
{
fstream outfile;
char choice='y';
while(choice=='y')
{
clrscr();
char ch;
//update employee file
outfile.open("employee.dat",ios::app);//open file in append mode
emp.get_data();//get information from the user
outfile.write((char*)&emp,sizeof(emp));//write in the file
outfile.flush();
outfile.close();//close file
add_pay_object(emp.employee_num,emp.employee_name,emp.desig_nation,
emp.basic_salary);
cout<<" ANY MORE EMPLOYEE TO BE ADDED---------------->";
cin>>choice;
}
}
//this function displays the contents of file of emps
void employee::show_object()
{
fstream infile;
infile.open("employee.dat",ios::in);//open file for reading
infile.seekg(0,ios::beg);//set file pointer to the begining of the file
infile.read((char*)&emp,sizeof(emp));//read the first record
while(!infile.eof())
{
emp.show_data();//display record
infile.read((char*)&emp,sizeof(emp));//read the next record
}
}
//this function deletes the record of an employee
void employee::del_object()
{
int code;
fstream infile,outfile;
cout< <" ENTER THE MEMBERSHIP NO.TO BE DELETED--------->";
cin>>code;
//update emp file
outfile.open("tempfile.dat",ios::app);//open temporary file
infile.open("employee.dat",ios::in);//open employee file
infile.seekg(0,ios::beg);//set file pointer to the begining of the file
infile.read((char*)&emp,sizeof(emp));//read the first record
while(!infile.eof())
{
if(emp.employee_num!=code)//if this record is not to be deleted
//write in temporary file
outfile.write((char*)&emp,sizeof(emp));
infile.read((char*)&emp,sizeof(emp));//read the next record
}
infile.close();//close employee file
outfile.close();//close temporary file
remove("employee.dat");//delete old employee file
rename("tempfile.dat","employee.dat");//temporary file becomes new
//employee file
del_pay_object(code);
}
//this function modifies information regarding an employee
void employee::modify_object()
{
fstream file;
int mod_choice;
int code;
do
{//display modify menu
clrscr();
cout< <" MODIFY MENU ";
cout<<" -------------------";
cout<<" CHANGED ADDRESS ....1";
cout<<" CHANGE DESIGNATION ....2";
cout<<" CHANGE BASIC SALARY ....3";
cout<<" EXIT MODIFY MENU ....4";
cout<<" ENTER YOUR CHOICE NO.----------->";
cin>>mod_choice;
if(mod_choice!=4)
{
cout< <" ENTER THE EMPLOYEE NUMBER--------->";
cin>>code;
file.open("employee.dat",ios::in|ios::out);//open the file for
// reading/writing
file.seekg(0,ios::beg);//set file pointer to the begining of the file
file.read((char*)&emp,sizeof(emp));//read first record
int n=file.tellg();//tell where we are
while(!file.eof())
{
if(code==emp.employee_num)//record found
{
switch(mod_choice)
{
case 1 : clrscr();
//get new information
cout< <" ENTER THE NEW ADDRESS-------------->";
gets(emp.employee_address);
file.seekg(n-sizeof(emp));//set file pointer to the record
//to be modified
file.write((char*)&emp,sizeof(emp));//update record
file.flush();
break;
case 2 : clrscr();
//get new information
cout< <" ENTER THE NEW DESIGNATION------------>";
gets(desig_nation);
file.seekg(n-sizeof(emp));//set file pointer to the record
//to be changed
file.write((char*)&emp,sizeof(emp));//update record
file.flush();
modify_pay_object(code,desig_nation);
break;
case 3 : clrscr();
//get new information
cout< <" ENTER NEW BASIC SALARY-------------->";
cin>>basic_salary;
file.seekg(n-sizeof(emp));//set file pointer to the record
//to be modified
file.write((char*)&emp,sizeof(emp));
file.flush();
modify_basic(code,basic_salary);
break;
}//end of switch
}//end if
file.read((char*)&emp,sizeof(emp));//raed next record
n=file.tellg();//tell where we are
}//end while
file.close();
}//end if
}//end do while loop
while(mod_choice!=4);
clrscr();
cout< <" YOU ENDED THE MODIFY SESSION ";
cout<<" THANK YOU!";
delay(700);
}
//this function searches information on the basis of a given field
void employee::search_object()
{
fstream infile;
int search_choice;
int phno;
int code;
char name[25];
do
{
int counter=0;//initialize counter to zero
clrscr();
//display search menu
cout<<" SEARCH MENU ";
cout<<" ----------------------";
cout<<" EMPLOYEE CODE ....1";
cout<<" EMPLOYEE NAME ....2";
cout<<" EXIT ....3";
cout<<" ENTER YOUR CHOICE NO.---------->";
cin>>search_choice;
switch(search_choice)
{
case 1 : clrscr();
cout< <" ENTER THE MEMBER CODE TO BE SEARCHED ----------->";
cin>>code;//get record no.
infile.open("employee.dat",ios::in);//open file for reading
infile.seekg(0,ios::beg);//set file pointer to the begining
// of the file
infile.read((char*)&emp,sizeof(emp));//read first record
while(!infile.eof())
{
if(emp.employee_num==code)
{ //record found
counter ++; //increment counter
emp.show_data();//display record
}
infile.read((char*)&emp,sizeof(emp));//read next record
}
infile.close();//if end of file , close file
gotoxy(22,20);
cout< <"RECORDS FOUND="< getch();//wait for key press
break;
case 2 : clrscr();
cout<<" ENTER THE NAME TO BE SEARCHED----------->";
cin>>name;
infile.open("employee.dat",ios::in);//open file for reading
infile.seekg(0,ios::beg);//set file pointer to the begining of
// the file
infile.read((char*)&emp,sizeof(emp));//read first record
while(!infile.eof())
{
if(strcmpi(emp.employee_name,name)==0)
{ //record found
counter++;//increment counter
emp.show_data();//display record
}
infile.read((char*)&emp,sizeof(emp));//read next record
}
infile.close();//if end of file , close file
gotoxy(22,20);
cout< <"RECORDS FOUND="< getch();//wait for key press
break;
case 3 : clrscr();
gotoxy(22,15);//set position for display
cout<<"YOU ENDED THE SEARCH SESSION";
gotoxy(27,18);
cout<<"THANK YOU!";
delay(700);//wait for some time
break;
}
}
while(search_choice!=3);
}
//this function generates reports
void payfile::reports()
{
fstream infile;
int report_choice;
do
{ //display report menu
clrscr();
cout<<" REPORT MENU ";
cout<<" ----------------------------";
cout<<" LIST OF ALL EMPLOYEES ....1";
cout<<" SALARY STATEMENTS OF ALL EMPLOYEES ....2";
cout<<" SALARY SLIP OF ALL EMPLOYEES ....3";
cout<<" EXIT REPORTS SESSION ....4";
cout<<" REPORT ON WHAT ? < ENTER CHOICE NO.>------->";
cin>>report_choice;
switch(report_choice)
{
case 1 : clrscr();
emp.show_object();
break;
case 2 : clrscr();
cout< <" -------------------------------------------------";
cout<<" RAJ CORPORATION ";
cout<<" -------------------------------------------------";
cout<<" EMP.NO. EMP.NAME DESIG ";
cout<<" BASIC DA HRA CCA CONVEYANCE GROSS PAY";
cout<<" PF ITAX OTHER DED. ******* NET PAY ";
cout<<" ---------------------------------------------------- ";
infile.open("payfile.dat",ios::in);//open payfile for reading
infile.seekg(0,ios::beg);//set file pointer to the begining
// of the file
infile.read((char*)&pay,sizeof(pay));//read the first record
while(!infile.eof())
{
cout<<" ";//leave some space
cout< < < < < cout< < < cout<<"EARNINGS:-";
cout< < < < < < < < < < < < < < < < cout<<"DEDUCTIONS :- ";
cout< < < < < < < < < < <<"************"
< < infile.read((char*)&pay,sizeof(pay));//read next record
}
infile.close();
gotoxy(22,24);
cout<<"PRESS ANY KEY TO CONTINUE";
getch();//wait for keypress
break;
case 3 : clrscr();
char ch,month[9];
cout<<" ENTER CURRENT DATE <>--------->";
cin>>current_date.dd>>ch
>>current_date.mm>>ch
>>current_date.yyyy;
switch(current_date.mm)
{ //get month name
case 1 : strcpy(month,"JANUARY");
break;
case 2 : strcpy(month,"FEBRUARY");
break;
case 3 : strcpy(month,"MARCH");
break;
case 4 : strcpy(month,"APRIL");
break;
case 5 : strcpy(month,"MAY");
break;
case 6 : strcpy(month,"JUNE");
break;
case 7 : strcpy(month,"JULY");
break;
case 8 : strcpy(month,"AUGUST");
break;
case 9 : strcpy(month,"SEPTEMBER");
break;
case 10 :strcpy(month,"OCTOBER");
break;
case 11 :strcpy(month,"NOVEMBER");
break;
case 12 :strcpy(month,"DECEMBER");
break;
}
infile.open("payfile.dat",ios::in);//open pay file for reading
infile.seekg(0,ios::beg);//set file pointer to the begining
// of the file
infile.read((char*)&pay,sizeof(pay));//read first record
while(!infile.eof())
{
clrscr();
cout< <" -----------------------------------------------------------";
cout<<" RAJ CORPORATION ";
cout<<" SALARY SLIP FOR THE MONTH OF "<cout<<" -----------------------------------------------------------";
cout<<" EMPLOYEE NO. :"< // justified output
< < cout<<" NAME:";
cout< < < cout<<" EARNINGS DEDUCTIONS ";
cout<<" ----------------- ----------------";
cout<<" BASIC : RS."< < < < < cout<<" PF : RS.";
cout< < < < < cout<<" DA : RS.";
cout< < < < < cout<<" ITAX : RS.";
cout< < < < < cout<<" HRA : RS.";
cout< < < < < cout<<" OTHER DEDUCTIONS : RS.";
cout< < < < < cout<<" CCA : RS.";
cout< < < < < cout<<" CONVEYANCE : RS.";
cout< < < < < cout<<" GROSS PAY : RS.";
cout< < < < < cout<<" TOTAL DEDUCTIONS : RS.";
cout< < < < < cout<<" NET PAY : RS.";
cout< < < < < cout<<" ---------------------------------------------------";
cout<<" SIGNATORY AUTHORITY";
cout<<" ---------------------------------------------------";
cout<<" ---------------------------------------------------";
gotoxy(22,24);
cout<<"PRESS ANY KEY TO CONTINUE";
getch();//wait for keypress
infile.read((char*)&pay,sizeof(pay));//read next record
}
infile.close();
break;
case 4 : clrscr();
gotoxy(22,15);
cout<<"YOU ENDED THE REPORT SESSION ";
gotoxy(27,18);
cout<<"THANK YOU!";
delay(700);
break;
}
}
while(report_choice!=4);
}
//this is the main function
void main()
{
int main_choice;
do
{ //display main menu
clrscr();
gotoxy(22,7);
cout<<" MAIN MENU ";
gotoxy(22,8);
cout<<"-----------------------";
gotoxy(22,10);
cout<<"REGISTER A NEW EMPLOYEE ....1";
gotoxy(22,11);
cout<<"REMOVE AN EMPLOYEE ....2";
gotoxy(22,12);
cout<<"MODIFY INFORMATION ABOUT AN EMPLOYEE ....3";
gotoxy(22,13);
cout<<"SEARCH FOR INFORMATION ABOUT AN EMPLOYEE ....4";
gotoxy(22,14);
cout<<"UPDATE MONTHLY PAY FILE ....5";
gotoxy(22,15);
cout<<"REPORTS ....6";
gotoxy(22,16);
cout<<"EXIT ....7";
gotoxy(25,20);
cout<<"ENTER YOUR CHOICE NO.-------------->";
cin>>main_choice;
switch(main_choice)
{
case 1 : emp.add_object();//call function to register a new employee
break;
case 2 : emp.del_object();//call function to delete the record of
// an employee
break;
case 3 : emp.modify_object();//this function can modify information
break;
case 4 : emp.search_object();//this function searches information
// about an employee
break;
case 5 : pay.update_pay_file();//this function generates
// monthly pay file
break;
case 6 : pay.reports();//this function generate reports
break;
case 7 : clrscr();
gotoxy(25,10);
cout< <"YOU ENDED THE SESSION ";
gotoxy(27,12);
cout<<"THANK YOU!";
delay(1000);
break;
}
}
while(main_choice!=7);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.