Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need coding for c++ A company pays its employees weekly. The employees are of fo

ID: 3690889 • Letter: N

Question

need coding for c++

A company pays its employees weekly. The employees are of four types: Salaried employees are paid a fixed weekly salary regardless of the number of hours worked, hourly employees are paid by the hour and receive overtime pay for all hours worked in excess of 40 hours, commission employees are paid a percentage of their sales and base-salary-plus-commission employees receive a base salary plus a percentage of their sales. For the current pay period, the company has decided to reward base-salary-plus-commission employees by adding 10 percent to their base salaries. The company wants to implement a C++ program that performs its payroll calculations polymorphically.

Your project should demonstrate:

Header files

Classes and subclasses

Multiple constructors

Destructor

Abstract Base class

Inheritance / Polymorphism

Pointers

Static variables & functions

Exceptions

Templates

Binary File I/O with random access

Extra points for:

Recursion

Virtual function or class

Linked lists / Stacks / Queues

Binary search trees

Overloaded operators

A “friend” function

Don’t forget: pseudocode & comments!!!

Explanation / Answer

#include #include #include #include #include #include #include #include//FOR GRAPHICS #include #include//FOR DELAY ETC. #include //#include "box.h"int gdriver = DETECT, gmode, errorcode; //Meant for the opening page//For the Welcome Screenvoid smile(void) { int midx,midy; initgraph(&gdriver, &gmode, "d:\turboc3"); errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ { printf("Graphics error: %s ", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(0); } setlinestyle(USERBIT_LINE,1,1); rectangle(4,6,620,460); midx = getmaxx() / 2; midy = getmaxy() / 2; settextjustify(CENTER_TEXT,CENTER_TEXT); setbkcolor(9); settextstyle(5,HORIZ_DIR,5); outtextxy(midx,midy,"MASTERMIND PVT.LTD"); getch(); closegraph(); } //structure declaration struct employee { long code; char name[30]; char address[60]; char dob[10]; char doj[10]; char desg[20]; char dept; float sal; char qlfn[20]; char flag; }erec; //function prototype declaration void newdata(); void accept_screen(); int generate_code(); void tabular_display(); void update(); void deldata(); void query(); void reports(); void gen_report(); void grp_report(); void pay_slip(); void smile(); fstream temp; //global open mode void main(void) { clrscr(); smile(); //to call the opening page fn // structure for implementing date struct date d; getdate(&d); int choice; temp.open("emp.dat",ios::binary|ios::in|ios::out); do { clrscr(); // mybox(2,1,4,77,3); gotoxy(20,3);textcolor(YELLOW);cprintf("EMPLOYEE DATABASE MANAGEMENT SYSTEM"); gotoxy(2,5);textcolor(10);cprintf("Dated : %d/%d/%d",d.da_day,d.da_mon,d.da_year); // mybox(6,1,21,77,3);// mybox(22,1,25,77,3);// section to set up a menu gotoxy(33,7);textcolor(YELLOW); cprintf("M E N U"); gotoxy(27,12); textcolor(WHITE);cprintf("1. New Employee"); gotoxy(27,13); cprintf("2. Update Employee"); gotoxy(27,14); cprintf("3. Delete Employee"); gotoxy(27,15); cprintf("4. Query Information"); gotoxy(27,16); cprintf("5. Reports/Salary Slip"); gotoxy(27,17); cprintf("6. Quit"); // section to read and implement choice gotoxy(24,23); textcolor(YELLOW); cprintf("Enter Choice 1/2/3/4/5/6 ?"); cin>>choice; switch(choice) { case 1 : newdata();break; case 2 : update(); break; case 3 : deldata();break; case 4 : query(); break; case 5 : reports();break; case 6 : exit(1); } } while (choice != 6); } //function to add new data to the table void newdata(void) { char ch; long emp_code; //make the data Entry Screen Available emp_code=generate_code(); accept_screen(); //open the file in append mode //Read the contents into the Records erec.code=emp_code; gotoxy(28,6); couterec.dept; gotoxy(28,20); fflush(stdin); cin>>erec.sal; gotoxy(28,22); fflush(stdin); gets(erec.qlfn); //write the record in to the table gotoxy(20,24); cprintf("Confirm Y/N?"); fflush(stdin); cin>>ch; if( ch=='y'|| ch=='Y') { erec.flag=' '; temp.seekp(0L,ios::end); temp.write((char*)&erec,sizeof(erec)); temp.clear(); } getch(); } //function to create data entry screen void accept_screen(void) { clrscr(); // mybox(2,1,4,77,11); gotoxy(27,3); textcolor(YELLOW); cprintf("New Employee details"); // mybox(5,1,23,77,11);// mybox(23,1,25,77,11);//DETAILS textcolor(WHITE); gotoxy(10,6); cprintf("Code "); gotoxy(10,8); cprintf("Name "); gotoxy(10,10); cprintf("Address "); gotoxy(10,12); cprintf("Date of Birth "); gotoxy(10,14); cprintf("Date of Joining "); gotoxy(10,16); cprintf("Designation :"); gotoxy(10,18); cprintf("Department [S/T/R/M/A ] "); gotoxy(10,20); cprintf("Basic Pay "); gotoxy(10,22); cprintf("Qualification "); //selection to accept details textbackground(BLUE); textcolor(WHITE); gotoxy(28,6); cprintf(" "); gotoxy(28,8); cprintf(" "); gotoxy(28,10); cprintf(" "); gotoxy(28,12); cprintf(" "); gotoxy(28,14); cprintf(" "); gotoxy(28,16); cprintf(" "); gotoxy(37,18); cprintf(" "); gotoxy(28,20); cprintf(" "); gotoxy(28,22); cprintf(" "); textbackground(BLACK); } //function to track the Employee code; int generate_code(void) { temp.seekg(0L,ios::beg); if(!temp.read((char*)&erec,sizeof(erec))) { temp.clear(); return(100); } else { temp.seekg(0L,ios::beg); //point the pointer to the begining of the file while(temp.read((char*)&erec,sizeof(erec))); { } temp.clear(); return(erec.code+1); } } //function to query record void query(void) { int ch,row=9; float tsal=0.0; char dpt; clrscr(); // mybox(2,1,4,77,3); gotoxy(25,3); textcolor(YELLOW); cprintf("View/Query Employee Details"); // mybox(4,1,6,77,3); textcolor(LIGHTGREEN); gotoxy(10,5); cprintf(" (1) All Records (2) Criteria Based Choce[1/2] ?"); gotoxy(73,5); fflush(stdin); cin>>ch; switch(ch) { case 1: { //create a tabular format for display using boxes tabular_display(); //call file for display temp.seekg(0L,ios::beg); textcolor(WHITE); while (temp.read((char *)&erec,sizeof(erec))) { gotoxy(2,row); cprintf("%d",erec.code); gotoxy(6,row); cprintf("%s",erec.name); gotoxy(28,row); cprintf("%s",erec.dob); gotoxy(38,row); cprintf("%s",erec.doj); gotoxy(48,row); cprintf("%s",erec.desg); gotoxy(58,row); cprintf("%c",erec.dept); gotoxy(62,row); cprintf("%8.2f",erec.sal); gotoxy(71,row); cprintf("%s",erec.qlfn); row++; if(row>22) { gotoxy(25,25); cprintf("More....."); getch(); textcolor(WHITE); clrscr(); // mybox(2,1,4,77,3); gotoxy(25,3); textcolor(YELLOW); cprintf("View/Query Employee Details"); textcolor(LIGHTGREEN); gotoxy(10,5); cprintf(" (1) All Records (2) Criteria based Choice[1/2] ??"); gotoxy(73,5); cout>dpt; //call the file for display temp.seekg(0L,ios::beg); textcolor(WHITE); //display section while(temp.read((char *)&erec,sizeof(erec))) { if(erec.dept==dpt) { tsal=tsal+erec.sal; gotoxy(2,row); cprintf("%d",erec.code); gotoxy(6,row); cprintf("%s",erec.name); gotoxy(28,row); cprintf("%s",erec.dob); gotoxy(38,row); cprintf("%s",erec.doj); gotoxy(48,row); cprintf("%s",erec.desg); gotoxy(58,row); cprintf("%c",erec.dept); gotoxy(62,row); cprintf("%8.2f",erec.sal); gotoxy(71,row); cprintf("%s",erec.qlfn); row++; if(row>22) { gotoxy(25,25); cprintf("More....."); getch(); textcolor(WHITE); clrscr(); // mybox(2,1,4,77,3); gotoxy(25,3); textcolor(YELLOW); cprintf("View/Query Employee Details"); textcolor(LIGHTGREEN); gotoxy(10,5); cprintf(" (1) All Records (2) Criteria based Choice[1/2] ??"); gotoxy(73,5); coutmcode; temp.seekg(0L,ios::beg); //position the pointer to the begining of the file //search the employee code while(temp.read((char *)&erec,sizeof(erec))) { if(erec.code==mcode) { erec.flag='*'; check = 1; pos=count*sizeof(erec); temp.seekp(pos,ios::beg); temp.write((char *)&erec,sizeof(erec)); break; } count++; } temp.clear(); //section to permanently remove the matching record if (check == 0) { gotoxy(25,15); cprintf("No matching Records For Deletion"); getch(); } else { ofstream tp; tp.open("temp.dat",ios::binary|ios::out); //position the pointer to the begining of the file temp.seekg(0L,ios::beg); //search the record marked for deletion while(temp.read((char *)&erec,sizeof(erec))) { if(erec.flag!='*') tp.write((char *)&erec,sizeof(erec)); } tp.clear(); tp.close(); temp.close(); remove("emp.dat"); rename("temp.dat","emp.dat"); temp.open("emp.dat",ios::binary|ios::in|ios::out); textcolor(YELLOW); gotoxy(25,15); cprintf("Record Successfully Deleted"); getch(); } } //section to update record void update(void) { int count=0,check=0; longint pos; long mcode; clrscr(); // mybox(2,1,4,77,3); gotoxy(25,3); textcolor(YELLOW); cprintf("Update Employee Details"); // mybox(5,1,8,77,3); textcolor(WHITE); gotoxy(25,7); cprintf("Enter Update Code >"); cin>>mcode; // mybox(9,1,25,77,3);//read File, display the original details & provide space to update //position to the begining of the file temp.seekg(0L,ios::beg); textcolor(WHITE); while(temp.read((char *)&erec,sizeof(erec))) { if(erec.code==mcode) { //first Display the original Contents check=1; gotoxy(2,12); cprintf("Code : %ld ",erec.code); gotoxy(2,13); cprintf("Name : %s ",erec.name); gotoxy(2,14); cprintf("Addr : %s ",erec.address); gotoxy(2,15); cprintf("Dob : %s ",erec.dob); gotoxy(2,16); cprintf("Doj : %s ",erec.doj); gotoxy(2,17); cprintf("Desg : %s ",erec.desg); gotoxy(2,18); cprintf("Dept : %c ",erec.dept); gotoxy(2,19); cprintf("Sal : %.2f ",erec.sal); gotoxy(2,20); cprintf("qlfn : %s ",erec.qlfn); //section to display pads for data entry textbackground(BLUE); textcolor(WHITE); gotoxy(30,12); cprintf(" "); gotoxy(30,13); cprintf(" "); gotoxy(30,14); cprintf(" "); gotoxy(30,15); cprintf(" "); gotoxy(30,16); cprintf(" "); gotoxy(30,17); cprintf(" "); gotoxy(30,18); cprintf(" "); gotoxy(30,19); cprintf(" "); gotoxy(30,19); cprintf(" "); //section to read data gotoxy(30,12); cin>>erec.code; gotoxy(30,13); fflush(stdin); gets(erec.name); gotoxy(30,14); fflush(stdin); gets(erec.address); gotoxy(30,15); fflush(stdin); gets(erec.dob); gotoxy(30,16); fflush(stdin); gets(erec.doj); gotoxy(30,17); fflush(stdin); gets(erec.desg); gotoxy(30,18); fflush(stdin); cin>>erec.dept; gotoxy(30,19); fflush(stdin); cin>>erec.sal; gotoxy(30,20); fflush(stdin); gets(erec.qlfn); textbackground(BLACK); erec.flag=' '; //position the put pointer so that the //existing record is qverwitten pos=count*sizeof(erec); temp.seekp(pos,ios::beg); temp.write((char *)&erec,sizeof(erec)); break; } //end of if statement count++; }//end of while loop if(check==0) { gotoxy(15,15); cprintf("No employee in File with matching code"); gotoxy(15,16); cprintf("Press Any Key ........."); getch(); } temp.clear(); } //section to print reports void reports(void) { int opt; do { clrscr(); // mybox(2,1,4,77,3); gotoxy(35,3); textcolor(YELLOW); cprintf("R E P O R T S"); // mybox(5,1,20,77,3); textcolor(WHITE); gotoxy(27,9); cprintf("1> General Report"); gotoxy(27,11); cprintf("2> Grouped Report"); gotoxy(27,13); cprintf("3> Salary Slip"); gotoxy(27,15); cprintf("4> Exit"); gotoxy(27,18); cprintf("Option 1/2/3/4 ?"); cin>>opt; switch(opt) { case 1:gen_report();break; case 2:grp_report();break; case 3:pay_slip();break; } } while (opt != 4); } // end of reportsvoid gen_report(void) { float tsum=0.0; struct date d; char stng[80]; ofstream temp_write_file; getdate(&d); // open the Report.dat file for reading temp_write_file.open("temp.dat",ios::out); temp_write_file