fatal error please help

Discussion in 'C++' started by coinjo, Dec 8, 2005.

  1. coinjo

    coinjo Guest

    #include<fstream>
    #include<iostream>
    #include<cstring>
    using namespace std;

    struct date
    {
    int day, month, year;
    };

    struct name
    {
    char array[20];
    };

    struct internee
    {
    int internee_id;
    name fname;
    name lname;
    int experience;
    date fdate;
    date ldate;
    };

    struct employee
    {
    int employee_id;
    name fname;
    name lname;
    int experience;
    int department_id;
    char rank[20];
    };

    struct department
    {
    int department_id;
    char department_name[20];
    int head_id;
    date sdate;
    int duration;
    };

    struct assignment
    {
    int employee_id;
    int internee_id;
    int duration;
    };

    int checkhead(int id, department d[])
    {
    int count=0;
    while(count<100)
    {
    if(d[count].head_id==id)
    {
    count=150;
    }
    count++;
    }
    if(count==150)
    {
    return 1;
    }

    else

    {

    return 0;
    }

    };


    int checkdate(internee i, employee e, department d[], int count1=0)
    {
    int count=0;

    while(count<count1)
    {
    if(e.department_id==d[count].department_id)
    {
    if(i.fdate.year<d[count].sdate.year)
    {
    return 1;
    count=count1;
    }
    else
    if(i.fdate.month<d[count].sdate.month)
    {
    return 1;
    count=count1;
    }
    else
    if(i.fdate.day<=d[count].sdate.day)
    {
    return 1;
    count=count1;
    }
    else
    {
    return 0;
    }
    }
    count++;
    }
    };


    int checkvacancy(assignment a[], employee e)
    {
    int count=0;
    int vacancy=0;

    while(count<10)
    {
    if(a[count].employee_id==e.employee_id)
    {
    vacancy++;
    }
    count++;
    }

    return vacancy;
    };

    int checkrank(employee e)
    {
    if(e.rank[0]=='S')
    {
    return 10;
    }
    else
    if(e.rank[0]=='T')
    {
    return 5;
    }
    else
    if(e.rank[0]=='J')
    {
    return 2;
    }
    };

    assignment assin(internee i, employee e, department d[])
    {
    assignment a;
    int count=0;

    while(count<10)
    {
    if(e.department_id==d[count].department_id)
    {
    a.duration=d[count].duration;
    count=10;
    }
    count++;
    }

    a.internee_id=i.internee_id;
    a.employee_id=e.employee_id;

    return a;
    };

    int average(employee e[], department d)
    {
    int count1=0;
    double average=0;
    int count2=0;

    while(count1<10)
    {
    if(d.department_id==e[count1].department_id)
    {
    average=average+e[count1].experience;
    count2++;
    }
    count1++;
    }

    return average/count2;
    };

    int greateraverage(int average, employee e)
    {
    if(e.experience>average)
    {
    return 1;
    }
    else
    {
    return 0;
    }
    };

    int lesser4(internee inte[], department d, employee e[], assignment
    assign[], int countemployee, int countinternee)
    {
    int count1=0;
    int count2=0;
    int count3=0;
    int count4=countinternee;
    int count5=0;

    while(count1<countemployee)
    {
    if(e[count1].department_id==d.department_id)
    {
    count2=0;

    while(count2<countinternee)
    {
    if(assign[count2].employee_id==e[count1].employee_id)
    {
    count3=0;

    while(count3<count4)
    {
    if(inte[count3].internee_id==assign[count2].internee_id)
    {
    if(inte[count3].experience<4)
    {
    count5++;
    }
    }
    count3++;
    }
    }
    count2++;
    }
    }
    count1++;
    }

    return count5;
    };

    int checkteamlead(employee e)
    {
    if(e.rank[0]=='T')
    {
    return 1;
    }

    else
    {
    return 0;
    }
    };

    void checkinternee(employee e, internee i[], int countinternee,
    assignment a[])
    {
    int count1=0;
    ofstream o;

    o.open("report2.txt");

    while(count1<countinternee)
    {
    if(a[count1].employee_id==e.employee_id)
    {
    o<<a[count1].internee_id<<endl;
    }
    count1++;
    }
    };

    void selectionSort(int list[], int length)
    {
    int index;
    int smallestIndex;
    int minIndex;
    int temp;

    for(index=0; index<length-1; index++)
    {
    smallestIndex=index;

    for(minIndex=index+1; minIndex<length; minIndex++)
    if(list[minIndex]<list[smallestIndex])
    smallestIndex=minIndex;
    temp=list[smallestIndex];
    list[smallestIndex]=list[index];
    list[index]=temp;
    }

    };

    int numberofleads(employee e[], int countemployees)
    {
    int count=0;
    int count1=0;


    while(count<countemployees)
    {
    if(e[count].rank[0]=='T')
    {
    count1++;
    }
    count++;
    }
    return count1;
    };


    int main()
    {

    ifstream a;
    ifstream b;
    ifstream c;
    ofstream d;
    ofstream e;

    int count=0;

    int selection=0;

    internee inte[10];
    employee emp[10];
    department dep[10];
    assignment assign[10];
    int interneecount=0;
    int employeecount=0;
    int head=0;
    int date=0;
    int vac=0;
    int rank=0;
    int assigncount=0;
    double ave=0;
    int departmentcount=0;
    int count1=0;
    int greaterthanaverage=0;
    int lessthan4=0;
    int countinternee=0;
    int countemployee=0;
    int countdepartment=0;

    a.open("internee.txt");

    while(!a.eof() && a>>inte[countinternee].internee_id)
    {
    a>>inte[countinternee].fname.array;

    a>>inte[countinternee].lname.array;

    a>>inte[countinternee].experience;

    a>>inte[countinternee].fdate.day;

    a>>inte[countinternee].fdate.month;

    a>>inte[countinternee].fdate.year;

    a>>inte[countinternee].ldate.day;

    a>>inte[countinternee].ldate.month;

    a>>inte[countinternee].ldate.year;

    countinternee++;
    }


    a.close();


    count=0;

    b.open("employee.txt");

    while(!b.eof() && b>>emp[countemployee].employee_id)
    {

    b>>emp[countemployee].fname.array;

    b>>emp[countemployee].lname.array;

    b>>emp[countemployee].experience;

    b>>emp[countemployee].department_id;

    b>>emp[countemployee].rank;

    countemployee++;

    }

    b.close();

    c.open("department.txt");

    while(!c.eof())
    {
    c>>dep[countdepartment].department_id;

    c>>dep[countdepartment].department_name;

    c>>dep[countdepartment].head_id;

    c>>dep[countdepartment].sdate.day;

    c>>dep[countdepartment].sdate.month;

    c>>dep[countdepartment].sdate.year;

    c>>dep[countdepartment].duration;

    countdepartment++;
    }

    count=0;

    c.close();

    while(selection!=6)
    {
    cout<<endl;
    cout<<" ENTER YOUR SELECTION"<<endl;
    cout<<endl;
    cout<<"1: Assignment"<<endl;
    cout<<"2: Report 1"<<endl;
    cout<<"3: Report 2"<<endl;
    cout<<"4: Addition of an Internee"<<endl;
    cout<<"5: Deletion of an Internee"<<endl;
    cout<<"6; Exit"<<endl;

    cin>>selection;

    if(selection==1)
    {
    d.open("assignment.txt");

    d<<"Internee ID Employee ID Duration"<<endl;
    while(interneecount<countinternee)
    {
    head=checkhead(emp[employeecount].employee_id,dep);

    if(head==1)
    {
    date=checkdate(inte[interneecount], emp[employeecount], dep,
    countemployee);

    if(date==1)
    {
    vac=checkvacancy(assign, emp[employeecount]);
    rank=checkrank(emp[employeecount]);

    if(rank-vac>0)
    {
    assign[assigncount]=assin(inte[interneecount], emp[employeecount],
    dep);
    d<<assign[assigncount].internee_id;
    d<<" ";
    d<<assign[assigncount].employee_id;
    d<<" ";
    d<<assign[assigncount].duration<<endl;
    assigncount++;
    interneecount++;
    }

    else
    {
    employeecount++;
    }

    }

    else
    {
    employeecount++;
    }

    }
    else
    {
    employeecount++;
    }
    }
    }

    else if(selection==3)
    {
    e.open("report2.txt");
    e<<"Department ID Department Name Head ID Start
    Date Duration Employees With Experience Greater Than Average"<<endl;
    while(count<countdepartment)
    {
    int count1=0;
    int stlength=0;
    ave=0;
    ave=average(emp, dep[count]);
    e<<dep[count].department_id;
    e<<" ";
    stlength=strlen(dep[count].department_name);
    while(count1<stlength)
    {
    e<<dep[count].department_name[count1];
    count1++;
    }

    e<<" ";

    e<<dep[count].head_id;
    e<<" ";
    e<<dep[count].sdate.day;
    e<<".";
    e<<dep[count].sdate.month;
    e<<".";
    e<<dep[count].sdate.year;
    e<<" ";
    e<<dep[count].duration;
    e<<" ";
    greaterthanaverage=0;

    count1=0;
    while(count1<countemployee)
    {
    if(emp[count1].employee_id==dep[count].department_id &&
    emp[count1].fname.array[0]!=0)
    {
    greaterthanaverage=greaterthanaverage+greateraverage(ave,
    emp[count1]);
    emp[count1].fname.array[0]=0;
    }
    count1++;
    }
    e<<greaterthanaverage<<endl;
    count++;
    }

    e<<endl;

    count=0;
    count1=0;

    e<<"Department ID Internees With Experience Less than 4 years";

    while(count<countdepartment)
    {
    e<<endl;
    e<<dep[count].department_id;
    e<<" ";
    lessthan4=0;

    lessthan4=lesser4(inte, dep[count], emp, assign, countemployee,
    countinternee);

    e<<lessthan4<<endl;
    count++;
    }
    }


    else if(selection==2)
    {
    int nofteamleads=0;
    nofteamleads=numberofleads(emp, countemployee);
    }
    }

    return 0;
    }



    department.txt contains

    21 Account 12 1 5 2005 8
    2 Marketing 15 1 7 2005 7
    13 HRM 7 1 12 2005 12
    45 Inventory 9 1 4 2005 10
    55 Cleaning 10 1 9 2005 4
    35 Security 13 1 6 2005 6
    52 pqr-dept 18 09 10 2005 9
    53 stu-dept 19 10 10 2005 10
    54 vwx-dept 20 11 11 2005 11
    55 uwv-dept 21 12 12 2005 12

    employee.txt contains
    12 Amna Ahmed 5 21 Seniorlead
    28 Xain Mubashar 7 2 TeamLead
    15 Mohammad Alvi 6 2 JuniorLead
    19 Jamayyal Tanweer 5 21 SeniorLead
    33 Tanweer Jamayyal 4 45 SeniorLead
    7 Usman Musharaf 3 13 SeniorLead
    11 Fizah Haider 8 45 TeamLead
    1 Haidder Fizeh 10 2 TeamLead
    9 Fahad Mudassar 3 45 TeamLead
    2 Amna Amjad 8 35 JuniorLead

    internee.txt contains

    12 Amna Ahmed 5 21 Seniorlead
    28 Xain Mubashar 7 2 TeamLead
    15 Mohammad Alvi 6 2 JuniorLead
    19 Jamayyal Tanweer 5 21 SeniorLead
    33 Tanweer Jamayyal 4 45 SeniorLead
    7 Usman Musharaf 3 13 SeniorLead
    11 Fizah Haider 8 45 TeamLead
    1 Haidder Fizeh 10 2 TeamLead
    9 Fahad Mudassar 3 45 TeamLead
    2 Amna Amjad 8 35 JuniorLead

    Please Help me!
     
    coinjo, Dec 8, 2005
    #1
    1. Advertising

  2. coinjo

    Howard Guest

    "coinjo" <> wrote in message
    news:...

    >
    > Please Help me!
    >


    Please help you what? You haven't given us any information about what your
    problem is. Are we supposed to guess?

    Do you have a debugger? You _really_ need to learn to use it, and step
    through your program, to see where it encounters a problem. Also, adding
    output statements (using cout) in various places in your app can help you
    see what the state of your program is at various places, what indexes you're
    using to access arrays, etc.

    Use the tools at hand, then if you have a problem which you can specify
    here, (such as "why does this line of code cause a crash?"), then ask again.
    But be specific, and do as much of the work yourself as possible.

    -Howard
     
    Howard, Dec 8, 2005
    #2
    1. Advertising

  3. coinjo

    Marcus Kwok Guest

    Marcus Kwok, Dec 8, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Polo Lee
    Replies:
    0
    Views:
    2,737
    Polo Lee
    Jul 7, 2003
  2. Kevin Flood
    Replies:
    0
    Views:
    1,028
    Kevin Flood
    Sep 8, 2004
  3. KK
    Replies:
    2
    Views:
    625
    Big Brian
    Oct 14, 2003
  4. Erik Sørensen

    Dev-C++ fatal error -help please

    Erik Sørensen, Sep 4, 2004, in forum: C++
    Replies:
    1
    Views:
    1,973
    Aguilar, James
    Sep 4, 2004
  5. Ann
    Replies:
    3
    Views:
    533
    Larry Brasfield
    Nov 1, 2004
Loading...

Share This Page