Share on Google+Share on Google+

Faisal Ansari
Managment
0 Answer(s)      6 years ago
Posted in : Java Beginners
Pl sir convert this C program to java program.

#include<graphics.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>

void lincol(int,int,int);
void delrec(void);
void edit(void);
void add(void);
void spec(void);
void all(void);
void head(int);
void box(int,int,int,int);
void clear(int,int,int,int);
void lin(int,int,int,int);

void main(void)
{
    int ch=0;
    while(1)
    {
        textattr(9);
        clrscr();
        lin(1,80,1,205);
        gotoxy(27,2);
        printf("SUFYAN COMPANY Pvt.(Ltd.)");
        gotoxy(35,3);
        printf("MAIN MENU");
        lin(1,80,4,205);
        gotoxy(28,7);
        printf("1. ADDITION OF RECORD");
        gotoxy(28,8);
        printf("2. DELETION OF RECORD");
        gotoxy(28,9);
        printf("3. EDITING OF RECORD");
        gotoxy(28,10);
        printf("4. SEE SPECIFIC RECORD");
        gotoxy(28,11);
        printf("5. SEE ALL RECORDS");
        gotoxy(28,12);
        printf("6. EXIT");
        gotoxy(28,20);
        printf("ENTER YOUR CHOICE :");
        fflush(stdin);
        scanf("%d",&ch);
        switch(ch)
        {
            case 1:
                add();
                break;
            case 2:
                delrec();
                break;
            case 3:
                edit();
                break;
            case 4:
                spec();
                break;
            case 5:
                all();
                break;
            case 6:
                exit(0);
        }
    }
}

void add(void)
{
    struct employee
    {
        int empno;
        int deptno;
        char deptname[20];
        char ename[30];
        char job[20];
        int grade;
        float basic;
    } emp;
    char ch;
    int i,eno,job,x,deptno;
    do
    {
        FILE *fpr;
        fpr=fopen("emp.dat","ab+");
        if(fpr==NULL)
        {
            gotoxy(3,22);
            printf("UNABLE TO OPEN FILE......");
            getch();
            return;
        }
        clrscr();
        fflush(stdin);
        gotoxy(27,2);
        printf("SUFYAN COMPANY Pvt. (Ltd.)");
        gotoxy(27,3);
        printf("  RECORD ADDITION ROUTINE  ");
        lin(1,80,4,205);
        gotoxy(10,7);
        fflush(stdin);
        eno=0;
        while(fread(&emp,sizeof(emp),1,fpr)!= NULL)
            eno++;
        emp.empno=eno+1;
        gotoxy(10,7);
        printf("EMPLOYEE NUMBER IS    :  %d",emp.empno);

        do
        {
            box(50,5,73,14);
            gotoxy(54,6); printf("DEPARTMENT NAMES\n");
            lin(51,72,7,196);
            gotoxy(53,8); printf("1--> MANAGEMENT");
            gotoxy(53,9); printf("2--> ACCOUNTS");
            gotoxy(53,10); printf("3--> COMPUTER");
            gotoxy(53,11); printf("4--> SALES");
            gotoxy(53,12); printf("5--> HUMAN RESOURSE");
            gotoxy(53,13); printf("6--> OTHERS");
            Again:
            gotoxy(10,8);
            printf("ENTER DEPARTMENT CODE :  ");
            scanf("%d",&deptno);
            if(deptno<1 || deptno>6)
            {
                gotoxy(5,23);
                printf("\a\a\aINVALID DEPARTMENT CODE");
                getch();
                clear(5,23,30,23);
                goto Again;
            }
            else
                emp.deptno=deptno;
            clear(50,5,73,14);
        } while(emp.deptno < 1 || emp.deptno > 6);

        if (emp.deptno==1) strcpy(emp.deptname,"MANAGEMENT");
        if (emp.deptno==2) strcpy(emp.deptname,"ACCOUNTS");
        if (emp.deptno==3) strcpy(emp.deptname,"COMPUTER");
        if (emp.deptno==4) strcpy(emp.deptname,"SALES");
        if (emp.deptno==5) strcpy(emp.deptname,"HUMAN RESOURSE");
        if (emp.deptno==6) strcpy(emp.deptname,"OTHERS");
        gotoxy(10,9); printf("DEPARTMENT NAME IS    :  %s",emp.deptname);
        do
        {
            if (deptno==1)
            {
                box(50,6,77,11);
                gotoxy(58,7); printf("MANAGEMENT");
                lin(51,76,8,196);
                gotoxy(53,9); printf("1-->  CHAIRMAN");
                gotoxy(53,10); printf("2-->  MANAGING DIRECTOR");
                gotoxy(10,10);
                fflush(stdin);
                printf("ENTER JOB CODE        :  ");
                scanf("%d",&job);
                if(job < 1 || job > 2)
                {
                    gotoxy(5,23);
                    printf("\aINVALID JOB NUMBER");
                    job = 5;
                    getch();
                    clear(5,23,30,23);
                }
                else

                {
                    if (job==1) strcpy(emp.job,"CHAIRMAN");
                    if (job==2) strcpy(emp.job,"MANAGING DIRECTOR");
                    clear(50,6,77,11);
                    gotoxy(10,10); printf("JOB IS                :  %s",emp.job);
                }
            }
            else if (deptno==2)
            {
                box(50,6,77,12);
                gotoxy(58,7); printf("ACCOUNTS");
                lin(51,76,8,196);
                gotoxy(53,9); printf("1-->  ACCOUNTS MANAGER");
                gotoxy(53,10); printf("2-->  ACCOUNTANT");
                gotoxy(53,11); printf("3-->  ACCOUNT ASSISTANT");
                gotoxy(10,10);
                fflush(stdin);
                printf("ENTER JOB CODE        :  ");
                scanf("%d",&job);
                if(job<1 || job>3)
                {
                    gotoxy(5,23);
                    printf("\a\a\aINVALID JOB NUMBER");
                    getch();
                    job=5;
                    clear(5,23,30,23);
                    clear(33,11,36,23);
                }
                else
                {
                    if (job==1) strcpy(emp.job,"ACCOUNTS MANAGER");
                    if (job==2) strcpy(emp.job,"ACCOUNTANT");
                    if (job==3) strcpy(emp.job,"ACCOUNT ASSISTANT");
                    clear(50,6,77,12);
                    gotoxy(10,10); printf("JOB IS                :  %s",emp.job);
                }
            }
            else if (deptno==3)
            {
                box(50,6,77,13);
                gotoxy(58,7); printf("COMPUTER");
                lin(51,76,8,196);
                gotoxy(53,9); printf("1-->  I.T. MANAGER");
                gotoxy(53,10); printf("2-->  SYSTEM ANALYST");
                gotoxy(53,11); printf("3-->  PROGRAMMER");
                gotoxy(53,12); printf("4-->  COMPUTER OPERATOR");
                gotoxy(10,10);
                fflush(stdin);
                printf("ENTER JOB CODE        :  ");
                scanf("%d",&job);
                if(job<1 || job>4)
                {
                    gotoxy(5,23);
                    printf("\a\a\aINVALID JOB NUMBER");
                    getch();
                    clear(5,23,30,23);
                    clear(33,11,36,23);
                }
                else
                {
                    if (job==1) strcpy(emp.job,"I.T. MANAGER");
                    if (job==2) strcpy(emp.job,"SYSTEM ANALYST");
                    if (job==3) strcpy(emp.job,"PROGRAMMER");
                    if (job==4) strcpy(emp.job,"COMPUTER OPERATOR");
                    clear(50,6,77,13);
                    gotoxy(10,10); printf("JOB IS                :  %s",emp.job);
                }
            }
            else if (deptno==4)
            {
                box(50,6,77,12);
                gotoxy(58,7); printf("SALES");
                lin(51,76,8,196);
                gotoxy(53,9); printf("1-->  SALES MANAGER");
                gotoxy(53,10); printf("2-->  SALES SUPERVISOR");
                gotoxy(53,11); printf("3-->  SALESMAN");
                gotoxy(10,10);
                fflush(stdin);
                printf("ENTER JOB CODE        :  ");
                scanf("%d",&job);
                if(job<1 || job>3)
                {
                    gotoxy(5,23);
                    printf("\a\a\aINVALID JOB NUMBER");
                    getch();
                    job=5;
                    clear(5,23,30,23);
                    clear(33,11,36,23);
                }
                else
                {
                    if (job==1) strcpy(emp.job,"SALES MANAGER");
                    if (job==2) strcpy(emp.job,"SALES SUPERVISOR");
                    if (job==3) strcpy(emp.job,"SALESMAN");
                    clear(50,6,77,12);
                    gotoxy(10,10); printf("JOB IS                :  %s",emp.job);
                }
            }
            else if (deptno==5)
            {
                box(50,6,77,10);
                gotoxy(58,7); printf("OTHERS");
                lin(51,76,8,196);
                gotoxy(53,9); printf("1--> H.R. MANAGER");
                gotoxy(10,10);
                fflush(stdin);
                printf("ENTER JOB CODE        :  ");
                scanf("%d",&job);
                if(job!=1)
                {
                    gotoxy(5,23);
                    printf("\a\a\aINVALID JOB NUMBER");
                    getch();
                    job=5;
                    clear(5,23,30,23);
                    clear(33,11,36,23);
                }
                else
                {
                    strcpy(emp.job,"H.R. MANAGER");
                    clear(50,6,77,12);
                    gotoxy(10,10); printf("JOB IS                :  %s",emp.job);
                }
            }
            else if (deptno==6)
            {
                box(50,6,77,12);
                gotoxy(58,7); printf("OTHERS");
                lin(51,76,8,196);
                gotoxy(53,9); printf("1--> CLERCK");
                gotoxy(53,10); printf("2--> GUARD");
                gotoxy(53,11); printf("3--> PEON");
                gotoxy(10,10);
                fflush(stdin);
                printf("ENTER JOB CODE        :  ");
                scanf("%d",&job);
                if(job<1 || job>3)
                {
                    gotoxy(5,23);
                    printf("\a\a\aINVALID JOB NUMBER");
                    getch();
                    job = 5;
                    clear(5,23,30,23);
                    clear(33,11,36,23);
                }
                else
                {
                    if (job==1) strcpy(emp.job,"CLERCK");
                    if (job==2) strcpy(emp.job,"GUARD");
                    if (job==3) strcpy(emp.job,"PEON");
                    clear(50,6,77,12);
                    gotoxy(10,10); printf("JOB IS                :  %s",emp.job);
                }
            }
        } while(job<1 || job>4);
        gotoxy(10,11);printf("ENTER EMPLOYEE NAME   :  ");
        fflush(stdin);
        gets(emp.ename);
        strupr(emp.ename);
        gotoxy(10,11);printf("EMPLOYEE NAME         :  %s",emp.ename);
        gotoxy(10,12);printf("ENTER BASIC SALARY    :  ");
        fflush(stdin);
        scanf("%f",&emp.basic);
        gotoxy(10,10);
        if(strcmp(emp.job,"CHAIRMAN")==0) emp.grade=1;
         else if(strcmp(emp.job,"MANAGING DIRECTOR")==0) emp.grade=1;
            else if(strcmp(emp.job,"SALES MANAGER")==0) emp.grade=2;
             else if(strcmp(emp.job,"H.R. MANAGER")==0) emp.grade=2;
            else if(strcmp(emp.job,"I.T. MANAGER")==0) emp.grade=2;
             else if(strcmp(emp.job,"ACCOUNTS MANAGER")==0) emp.grade=2;
                else if(strcmp(emp.job,"SALES SUPERVISOR")==0) emp.grade=3;
                 else if(strcmp(emp.job,"SYSTEM ANALYST")==0) emp.grade=3;
                else if(strcmp(emp.job,"PROGRAMMER")==0) emp.grade=3;
                 else if(strcmp(emp.job,"ACCOUNTANT")==0) emp.grade=4;
                    else if(strcmp(emp.job,"SALESMAN")==0) emp.grade=4;
                     else if(strcmp(emp.job,"COMPUTER OPERATOR")==0) emp.grade=4;
                    else if(strcmp(emp.job,"ACCOUNT ASSISTANT")==0) emp.grade=4;
                     else if(strcmp(emp.job,"CLERCK")==0) emp.grade=5;
                        else if(strcmp(emp.job,"GUARD")==0) emp.grade=5;
                         else if(strcmp(emp.job,"PEON")==0) emp.grade=5;
        fseek(fpr,0,SEEK_END);
        fwrite(&emp,sizeof(emp),1,fpr);
        fclose(fpr);
        gotoxy(15,20);
        fflush(stdin);
        printf("ENTER MORE RECORDS ? [Y/N] : ");
        ch=getche();
    }
    while(ch=='Y' || ch=='y');
    return;
}

void spec(void)
{
    struct employee
    {
        int empno;
        int deptno;
        char deptname[20];
        char ename[30];
        char job[20];
        int grade;
        float basic;
    } emp;
    int i,eno,f;
    float hrent,tax,med,conv,gross,net,yp;
    char ch;
    do
    {
        FILE *fpr;
        clrscr();
        fpr=fopen("emp.dat","rb");
        if (fpr==NULL)
        {
            gotoxy(3,23);
            printf("\aUNABLE TO OPEN FILE");
            return;
        }
        f=0;
        clrscr();
        fflush(stdin);
        gotoxy(27,2);
        printf(" HUUA COMPANY PVT (LTD) ");
        gotoxy(27,3);
        printf("SPECIFIC RECORD DISPLAY");
        lin(1,80,4,196);
        gotoxy(20,6);
        printf("ENTER EMPLOYEE NO : ");
        scanf("%d",&eno);
        while(fread(&emp,sizeof(emp),1,fpr)!= NULL)
        {
            if(emp.empno==eno)
            {
                if (emp.grade==5)
                {
                    hrent=(emp.basic/100)*15;
                    med=(emp.basic/100)*15;
                    conv=(emp.basic/100)*10;
                }
                else if (emp.grade==4)
                {
                    hrent=(emp.basic/100)*18;
                    med=(emp.basic/100)*18;
                    conv=(emp.basic/100)*14;
                }
                else if (emp.grade==3)
                {
                    hrent=(emp.basic/100)*22;
                    med=(emp.basic/100)*22;
                    conv=(emp.basic/100)*18;
                 }
                 else if (emp.grade==2)
                 {
                    hrent=(emp.basic/100)*30;
                    med=(emp.basic/100)*30;
                    conv=(emp.basic/100)*25;
                 }
                 else if (emp.grade==1)
                 {
                    hrent=(emp.basic/100)*35;
                    med=(emp.basic/100)*35;
                    conv=(emp.basic/100)*30;
                 }
                yp=emp.basic*12;
                if(yp>=60000 && yp<100000)
                    tax=((emp.basic*8)/100);
                    else if(yp>=60000 && yp<150000)
                        tax=((emp.basic*12)/100);
                        else if(yp>=150000)
                            tax=((emp.basic*16)/100);
                                else tax=0;
                gross=emp.basic+med+conv+hrent;
                net=gross-tax;
                f=1;
                gotoxy(20,8);
                printf("EMPLOYEE NAME       : ");puts(emp.ename);
                gotoxy(20,9);
                printf("JOB                 : ");puts(emp.job);
                gotoxy(20,10);
                printf("GRADE               : %d",emp.grade);
                gotoxy(20,11);
                printf("DEPARTMENT NAME     : ");puts(emp.deptname);
                gotoxy(20,12);
                printf("BASIC SALARY        : %.1f",emp.basic);
                gotoxy(20,13);
                printf("HOUSE RENT          : %.1f",hrent);
                gotoxy(20,14);
                printf("MEDICAL ALLOWANCE   : %.1f",med);
                gotoxy(20,15);
                printf("CONVENCE ALLOWANCE  : %.1f",conv);
                lin(20,48,16,196);
                gotoxy(20,17);
                printf("GROSS PAY           : %.1f",gross);
                gotoxy(20,18);
                printf("TAX CHARGED         : %.1f",tax);
                lin(20,48,19,205);
                gotoxy(20,20);
                printf("NET PAY             : %.1f",net);
                lin(20,48,21,205);
            }
        }
        if (f==0)
        {
            gotoxy(20,23);
            printf("\aRECORD NOT FOUND");
            getch();

        }
        fclose(fpr);
        gotoxy(20,23);
        printf("SEE MORE RECORDS [Y/N] : ");
        fflush (stdin);
        ch=getche();
    }while (ch =='Y'|| ch=='y');
}

void all(void)
{
    struct employee
    {
        int empno;
        int deptno;
        char deptname[20];
        char ename[30];
        char job[20];
        int grade;
        float basic;
    }emp;
    float hrent,tax,med,conv,gross,net,yp;
    int p=0,r=0;
    FILE *fpr;
    fpr=fopen("emp.dat","rb");
    if (fpr==NULL)
    {
        printf("UNABLE TO OPEN FILE");
        return;
    }
    clrscr();
    p=1;
    head(p);
    r=8;
    lincol(r,23,6);
    lincol(r,23,29);
    lincol(r,23,37);
    lincol(r,23,44);
    lincol(r,23,50);
    lincol(r,23,57);
    lincol(r,23,65);
    lincol(r,23,71);
    while(fread(&emp,sizeof(emp),1,fpr)!=NULL)
    {
        if (emp.grade==5)
        {
            hrent=(emp.basic/100)*15;
            med=(emp.basic/100)*15;
            conv=(emp.basic/100)*10;
        }
        else if (emp.grade==4)
        {
            hrent=(emp.basic/100)*18;
            med=(emp.basic/100)*18;
            conv=(emp.basic/100)*14;
        }
        else if (emp.grade==3)
        {
            hrent=(emp.basic/100)*22;
            med=(emp.basic/100)*22;
            conv=(emp.basic/100)*18;
        }
        else if (emp.grade==2)
        {
            hrent=(emp.basic/100)*30;
            med=(emp.basic/100)*30;
            conv=(emp.basic/100)*25;
        }
        else if (emp.grade==1)
        {
            hrent=(emp.basic/100)*35;
            med=(emp.basic/100)*35;
            conv=(emp.basic/100)*30;
        }
        yp=emp.basic*12;
        if(yp>=60000 && yp<100000)
            tax=((emp.basic*8)/100);
            else if(yp>=60000 && yp<150000)
                tax=((emp.basic*12)/100);
                else if(yp>=150000)
                    tax=((emp.basic*16)/100);
                        else tax=0;
        gross=emp.basic+med+conv+hrent;
        net=gross-tax;
        gotoxy(2,r);
        printf("%-2d",emp.empno);
        gotoxy(7, r) ;
        puts(emp.ename);
        gotoxy(30,r);
        printf("%.f",emp.basic) ;
        gotoxy(38,r);
        printf("%.f",conv);
        gotoxy(45,r);
        printf("%.f",hrent);
        gotoxy(51,r);
        printf("%.f",med);
        gotoxy(58,r);
        printf("%.f",gross);
        gotoxy(66,r);
        printf("%.f",tax);
        gotoxy(72,r++);
        printf("%.f",net);
        if (r>22)
        {
            gotoxy(55,24);
            printf("PRESS ANY KEY TO CONTINUE");
            getch();
            p=p+1;
            head(p);
            r=8;
        }
    }
    fclose(fpr);
    gotoxy(58,24);
    printf("PRESS ANY KEY TO EXIT");
    getch();
}

void head(int pno)
{
    int i;
    clrscr();
    gotoxy(27,1); printf ("SUFYAN COMPANY Pvt(Ltd)");
    gotoxy(27,2); printf ("ALL RECORDS DISPLAY");
    lin(1,80,3,196);
    gotoxy(1,4);printf("Page # : %d",pno);
    lin(1,80,5,196);
    gotoxy(1,6);
    printf("EMPNO");
    gotoxy(7,6) ;
    printf("EMPLOYEE NAME");
    gotoxy(30,6);
    printf("BASIC");
    gotoxy(38,6);
    printf("CONV.");
    gotoxy(44,6);
    printf("H.RENT");
    gotoxy(51,6);
    printf("MED.");
    gotoxy(58,6);
    printf("GROSS");
    gotoxy(66,6) ;
    printf("TAX");
    gotoxy(72,6);
    printf("NET");
    lin(1,80,7,196);
}

void edit(void)
{
    struct employee
    {
        int empno;
        int deptno;
        char deptname[20];
        char ename[30];
        char job[20];
        int grade;
        float basic;
    } emp,emp1;
    int i;
    char ch;
    int eno,f=0,job,deptno;
    long int b;
    do
    {
        f=0;
        FILE *fpr,*fpr1;
        fpr=fopen("emp.dat","rb+");
        fpr1=fopen("dum.dat","ab+") ;
        if (fpr==NULL)
        {
            printf("UNABLE TO OPEN FILE....");
            break;
        }
        clrscr();
        gotoxy(27,2);
        printf("SUFYAN COMPANY PVT.(LTD) ");
        gotoxy(27,3);
        printf("RECORD EDITING ROUTINE");
        lin(1,80,4,205);
        fflush(stdin);
        gotoxy(3,7);
        printf ("ENTER EMPLOYEE NO TO EDIT : ");
        scanf("%d",&eno);
        while(fread(&emp,sizeof(emp),1,fpr) != NULL)
        {
            if (emp.empno==eno)
            {
                f=1;
                gotoxy (3,9);
                printf("EMPLOYEE NAME           : %s",emp.ename);
                gotoxy(3,10);
                printf("BASIC SALARY            : %.f",emp.basic);
                fflush(stdin);
                gotoxy(3,23);
                printf("CHANGE SALARY [Y/N]     : ");
                ch=getche();
                clear(3,23,35,23);
                if (ch=='Y' || ch=='y')
                {
                    gotoxy(3,12);
                    printf("ENTER NEW SALARY          : ");
                    scanf("%f",&emp.basic);
                    clear(3,10,30,10);
                    gotoxy(3,10);
                    printf("NEW SALARY              : %.f",emp.basic);
                }
                clear(3,11,45,15);
                gotoxy(3,11);
                printf("DEPARTMENT NAME         : %s",emp.deptname);
                gotoxy(3,23);
                printf("CHANGE DEPARTMENT [Y/N] : ");
                fflush(stdin);
                ch=getche();
                clear(3,23,35,23);
                if (ch=='Y' || ch=='y')
                {
                    do
                    {
                        box(50,5,73,14);
                        gotoxy(54,6); printf("DEPARTMENT NAMES\n");
                        lin(51,72,7,196);
                        gotoxy(53,8); printf("1--> MANAGEMENT");
                        gotoxy(53,9); printf("2--> ACCOUNTS");
                        gotoxy(53,10); printf("3--> COMPUTER");
                        gotoxy(53,11); printf("4--> SALES");
                        gotoxy(53,12); printf("5--> HUMAN RESOURSE");
                        gotoxy(53,13); printf("6--> OTHERS");
                        gotoxy(3,13);
                        printf("ENTER DEPARTMENT CODE :");
                        scanf("%d",&deptno);
                        if(deptno<1 || deptno>6)
                        {
                            gotoxy(5,23);
                            printf("\a\a\aINVALID DEPARTMENT CODE");
                            getch();
                            clear(5,23,30,23);
                        }
                        else
                            emp.deptno=deptno;
                            clear(50,5,73,14);
                    } while(deptno<1||deptno>6);
                    if (deptno==1) strcpy(emp.deptname,"MANAGEMENT");
                    if (deptno==2) strcpy(emp.deptname,"ACCOUNTS");
                    if (deptno==3) strcpy(emp.deptname,"COMPUTER");
                    if (deptno==4) strcpy(emp.deptname,"SALES");
                    if (deptno==5) strcpy(emp.deptname,"HUMAN RESOURSE");
                    if (deptno==6) strcpy(emp.deptname,"OTHERS");
                    clear(3,11,40,11);
                    gotoxy(3,11);
                    printf("DEPARTMENT NAME IS      : %s",emp.deptname);
                    clear(3,12,45,15);
                }
                gotoxy(3,12);
                printf("EMPLOYEE JOB            : %s",emp.job);
                fflush(stdin);
                gotoxy(3,23);
                printf("CHANGE JOB [Y/N]        : ");
                ch=getche();
                clear(3,23,35,23);
                if (ch=='Y' || ch=='y')
                {
                    do
                    {
                        if (emp.deptno==1)
                        {
                            box(50,6,77,11);
                            gotoxy(58,7); printf("MANAGEMENT");
                            lin(51,76,8,196);
                            gotoxy(53,9); printf("1-->  CHAIRMAN");
                            gotoxy(53,10); printf("2-->  MANAGING DIRECTOR");
                            Again1:
                            gotoxy(3,14);
                            fflush(stdin);
                            printf("ENTER JOB CODE        :");
                            scanf("%d",&job);
                            if(job<1 || job>2)
                            {
                                gotoxy(5,23);
                                printf("\aINVALID JOB NUMBER");
                                job=5;
                                getch();
                                clear(5,23,30,23);
                                goto Again1;
                            }
                            else
                            {
                                if (job==1) strcpy(emp.job,"CHAIRMAN");
                                if (job==2) strcpy(emp.job,"MANAGING DIRECTOR");
                                clear(50,6,77,11);
                                clear(3,12,46,12);
                                gotoxy(3,12); printf("JOB IS                  : %s",emp.job);
                            }
                        }
                        else if (emp.deptno==2)
                        {
                            box(50,6,77,12);
                            gotoxy(58,7); printf("ACCOUNTS");
                            lin(51,76,8,196);
                            gotoxy(53,9); printf("1-->  ACCOUNTS MANAGER");
                            gotoxy(53,10); printf("2-->  ACCOUNTANT");
                            gotoxy(53,11); printf("3-->  ACCOUNT ASSISTANT");
                            Again2:
                            gotoxy(3,14);
                            fflush(stdin);
                            printf("ENTER JOB CODE        :");
                            scanf("%d",&job);
                            if(job<1 || job>3)
                            {
                                gotoxy(5,23);
                                printf("\a\a\aINVALID JOB NUMBER");
                                getch();
                                job=5;
                                clear(5,23,30,23);
                                goto Again2;
                            }
                                else
                            {
                                if (job==1) strcpy(emp.job,"ACCOUNTS MANAGER");
                                if (job==2) strcpy(emp.job,"ACCOUNTANT");
                                if (job==3) strcpy(emp.job,"ACCOUNT ASSISTANT");
                                clear(50,6,77,12);
                                clear(3,12,46,12);
                                gotoxy(3,12); printf("JOB IS                  : %s",emp.job);
                            }
                        }
else if (emp.deptno==3)
{
box(50,6,77,13);
gotoxy(58,7); printf("COMPUTER");
lin(51,76,8,196);
gotoxy(53,9); printf("1-->  I.T. MANAGER");
gotoxy(53,10); printf("2-->  SYSTEM ANALYST");
gotoxy(53,11); printf("3-->  PROGRAMMER");
gotoxy(53,12); printf("4-->  COMPUTER OPERATOR");
Again3:
gotoxy(3,14);
fflush(stdin);
printf("ENTER JOB CODE        :");
scanf("%d",&job);
if(job<1 || job>4)
{
gotoxy(5,23);
printf("\a\a\aINVALID JOB NUMBER");
getch();
clear(5,23,30,23);
goto Again3;
}
else
{
if (job==1) strcpy(emp.job,"I.T. MANAGER");
if (job==2) strcpy(emp.job,"SYSTEM ANALYST");
if (job==3) strcpy(emp.job,"PROGRAMMER");
if (job==4) strcpy(emp.job,"COMPUTER OPERATOR");
clear(50,6,77,13);
clear(3,12,46,12);
gotoxy(3,12); printf("JOB IS                  : %s",emp.job);
}
}
else if(emp.deptno==4)
        {
box(50,6,77,12);
gotoxy(58,7); printf("SALES");
lin(51,76,8,196);
gotoxy(53,9); printf("1-->  SALES MANAGER");
gotoxy(53,10); printf("2-->  SALES SUPERVISOR");
gotoxy(53,11); printf("3-->  SALESMAN");
Again4:
gotoxy(3,14);
fflush(stdin);
printf("ENTER JOB CODE        :");
scanf("%d",&job);
if(job<1 || job>3)
{
gotoxy(5,23);
printf("\a\a\aINVALID JOB NUMBER");
getch();
job=5;
clear(5,23,30,23);
goto Again4;
}
else
{
if (job==1) strcpy(emp.job,"SALES MANAGER");
if (job==2) strcpy(emp.job,"SALES SUPERVISOR");
if (job==3) strcpy(emp.job,"SALESMAN");
clear(50,6,77,12);
                                clear(3,12,46,12);
                                gotoxy(3,12); printf("JOB IS                  : %s",emp.job);
                            }
                            }
                            else if (deptno==5)
                            {
                             box(50,6,77,10);
                             gotoxy(58,7); printf("OTHERS");
                             lin(51,76,8,196);
                             gotoxy(53,9); printf("1--> H.R. MANAGER");
                             Again6:
                    gotoxy(3,14);
                fflush(stdin);
                printf("ENTER JOB CODE        :  ");
                scanf("%d",&job);
                if(job!=1)
                {
                    gotoxy(5,23);
                    printf("\a\a\aINVALID JOB NUMBER");
                    getch();
                    job=5;
                    clear(5,23,30,23);
                    goto Again6;
                }
                else
                {
                    strcpy(emp.job,"H.R. MANAGER");
                    clear(50,6,77,12);
                    gotoxy(3,12); printf("JOB IS                :  %s",emp.job);
                }
            }




                        else if (emp.deptno==6)
                        {
                            box(50,6,77,12);
                            gotoxy(58,7); printf("OTHERS");
                            lin(51,76,8,196);
                            gotoxy(53,9); printf("1--> CLERCK");
                            gotoxy(53,10); printf("2--> GUARD");
                            gotoxy(53,11); printf("3--> PEON");
                            gotoxy(3,14);
                            Again5:
                            fflush(stdin);
                            printf("ENTER JOB CODE        :");
                            scanf("%d",&job);
                            if(job<1 || job>3)
                            {
                                gotoxy(5,23);
                                printf("\a\a\aINVALID JOB NUMBER");
                                getch();
                                job=5;
                                clear(5,23,30,23);
                                goto Again5;
                            }
                            else
                            {
                                if (job==1) strcpy(emp.job,"CLERCK");
                                if (job==2) strcpy(emp.job,"GUARD");
                                if (job==3) strcpy(emp.job,"PEON");
                                clear(50,6,77,12);
                                clear(3,12,46,12);
                                gotoxy(3,12); printf("JOB IS                  : %s",emp.job);
                            }
                        }
                    }while(job<1 || job>16);
                    clear(3,13,45,15);
                }
                if(strcmp(emp.job,"CHAIRMAN")==0) emp.grade=1;
                 else if(strcmp(emp.job,"MANAGING DIRECTOR")==0) emp.grade=1;
                    else if(strcmp(emp.job,"SALES MANAGER")==0) emp.grade=2;
                     else if(strcmp(emp.job,"H.R. MANAGER")==0) emp.grade=2;
                        else if(strcmp(emp.job,"I.T. MANAGER")==0) emp.grade=2;
                         else if(strcmp(emp.job,"ACCOUNTS MANAGER")==0) emp.grade=2;
                            else if(strcmp(emp.job,"SALES SUPERVISOR")==0) emp.grade=3;
                             else if(strcmp(emp.job,"SYSTEM ANALYST")==0) emp.grade=3;
                                else if(strcmp(emp.job,"PROGRAMMER")==0) emp.grade=3;
                                 else if(strcmp(emp.job,"ACCOUNTANT")==0) emp.grade=4;
                                    else if(strcmp(emp.job,"SALESMAN")==0) emp.grade=4;
                                     else if(strcmp(emp.job,"COMPUTER OPERATOR")==0) emp.grade=4;
                                        else if(strcmp(emp.job,"ACCOUNT ASSISTANT")==0) emp.grade=4;
                                         else if(strcmp(emp.job,"CLERCK")==0) emp.grade=5;
                                            else if(strcmp(emp.job,"GUARD")==0) emp.grade=5;
                                             else if(strcmp(emp.job,"PEON")==0) emp.grade=5;
                fwrite(&emp,sizeof(emp),1,fpr1);
            }
            else
                fwrite(&emp,sizeof(emp),1,fpr1);
        }
        if (f==0)
        {
            gotoxy(3,20);
            printf("RECORD NOT FOUND");
        }
        fclose (fpr);
        fclose(fpr1);
        remove("emp.dat");
        rename("dum.dat","emp.dat");
        gotoxy(3,22);
        printf("EDIT MORE RECORDS [Y/N] : ");
        fflush(stdin);
        ch=getche();
    } while (ch=='Y' || ch == 'y');
}

void delrec(void)
{
    struct employee
    {
        int empno;
        int deptno;
        char deptname[20];
        char ename[30];
        char job[20];
        int grade;
        float basic;
    } emp;
    int eno,count;
    int i,f=0;
    char ch;
    clrscr();
    FILE *fpr,*fpr1;
    do
    {
        fpr=fopen("emp.dat","rb+");
        fpr1=fopen("dum.dat","ab+") ;
        if (fpr==NULL)
        {
            fflush(stdin);
            gotoxy(3,23);
            printf("UNABLE TO OPEN FILE....");
            getch();
            return;
        }
        clrscr();
        gotoxy(27,2);
        printf("HUUA COMPANY PVT(LTD)  ");
        gotoxy(27,3);
        printf("RECORD DELETION ROUTINE");
        lin(1,80,4,196);
        fflush(stdin);
        gotoxy(3,7);
        printf ("ENTER EMPLOYEE NO TO DELETE : ");
        scanf("%d",&eno);
        count=0;
        while(fread(&emp,sizeof(emp),1,fpr) != NULL)
        {
            if(emp.empno==eno)
            {
                f=1;
                gotoxy(3,9);
                printf("EMPLOYEE NAME : %s",emp.ename);
                gotoxy(3,11);
                printf("BASIC SALARY  : %g",emp.basic);
                gotoxy(3,13);
                printf("SURE TO DELETE THIS RECORD [Y,N] : ");
                fflush(stdin);
                ch=getche();
                if (ch=='Y'||ch=='y')
                {
                    gotoxy(3,15);
                    printf("RECORD SUCCESSFULLY DELETED");
                }
                else
                {
                    gotoxy(3,15);
                    printf("RECORD NOT DELETED");
                    if(ch!='Y'|| ch!='y')
                      {
                        emp.empno=++count;
                        fwrite(&emp,sizeof(emp),1,fpr1);
                      }
                }
            }
            else
            {
                emp.empno=++count;
                fwrite(&emp,sizeof(emp),1,fpr1);
            }
        }
        if (f==0)
        {
            gotoxy(3,22);
            printf("\a\aRECORD NOT FOUND");
            getch();
        }
        gotoxy(3,22);
        printf( "DELETE MORE RECORDS (Y,N] : ");
        fflush(stdin);
        ch=getche();
        fclose(fpr);
        fclose(fpr1);
        remove("emp.dat");
        rename("dum.dat","emp.dat");
    }
    while( ch=='Y' || ch=='y');
    fflush(stdin);
    fclose(fpr);
    getch();
}

void box(int x1,int y1,int x2,int y2)
{
    int x,y;
    for (x=x1;x<=x2;x++)
    {
        if (x==x1)
        {
            gotoxy(x,y2);
            printf("%c",200);
            gotoxy(x,y1);
            printf("%c",201);
        }
        else if (x==x2)
        {
            gotoxy(x,y1);
            printf("%c",187);
            gotoxy(x,y2);
            printf("%c",188);
        }
        else
        {
            gotoxy(x,y1);
            printf("%c",205);
            gotoxy(x,y2);
            printf("%c",205);
        }
    }
    for (y=y1+1;y<=y2-1;y++)
    {
        gotoxy(x1,y);
        printf("%c",186);
        gotoxy(x2,y);
        printf("%c",186);
    }
}

void lin(int p1,int p2,int y, int ch)
{
    int x;
    for (x=p1;x<=p2;x++)
    {
        gotoxy(x,y);
        printf("%c",ch);
    }
}
void clear (int x1, int y1, int x2, int y2)
{
    int i,j;
    for (i=y1;i<=y2;i++)
        for(j=x1;j<=x2;j++)
        {
            gotoxy(j,i);
            printf(" ");
        }
}

void lincol(int start,int end,int x)
{
    int y;
    for (y=start;y<=end;y++)
    {
        gotoxy(x,y);
        putch(179);
    }
}

Ads

View Answers









Related Tutorials/Questions & Answers:
Advertisements
java coding
java coding  Hi sir, WRITE A PROGRAMME TO MAKE EMPLOYMENT MANAGMENT HAVING COLORS AND FRAME IN IT,???? CAN U SUGGEST ME HOW TO MAKE IT IN CORE JAVA
JSP - JSP-Servlet
JSP  Hi! I am doing a project in JSP i.e. Library managment. In that I have to display current date in a text field as date of issue. I have tried using , but it is displaying with time.I dont want to display with time. I would
pure:variants Variant Management
managment the development process becomes more efficient, faster, and more
getting a problem in execution - Development process
getting a problem in execution  hi friends i have a problem in imcms content managment system it is a java content mangment system it is according to the installation procedure all the procedure is completed but it is getting
Java - Java Beginners
; public Billing(){ super("Nakasero Hospital Managment System [ Billing Maintance...; ButtonGroup bg; public Billing(){ super("Nakasero Hospital Managment System [ Billing
java - Java Beginners
p1,p2,p3,p4,p; ButtonGroup bg; public Billing(){ super("Nakasero Hospital Managment...("Nakasero Hospital Managment System [ Billing Maintance Module]"); l1=new
Gui - Java Beginners
("Nakasero Hospital Managment System [ Inpatient Maintance Module]"); setSize
VoIP Billing Solution
managment - let the dealer has his own scope in your system.   VoIP
Tutorials   
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized

Ads

 
Advertisement null

Ads