can you please locate where is the error in my code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marianne rosette bermil
    New Member
    • Sep 2010
    • 2

    #1

    can you please locate where is the error in my code?


    #include<stdio. h>
    #include<conio. h>


    #include<stdio. h>
    #include<conio. h>
    #include<string .h>
    #include<stdlib .h>
    #include<ctype. h>
    #include<proces s.h>
    #include<dos.h>


    FILE*source,*re ad;
    void update();
    void report();
    void bye();
    void maintenance();
    void payslip();
    void add();
    void edit();
    void menu();

    FILE *fp;
    char name[30],lastname[30];
    char h,code,hrs,rate ;
    int choice;

    main()
    {
    clrscr();
    {
    gotoxy(17,10);p rintf("WELCOME to Payroll System of");
    delay(200);
    }

    gotoxy(6,13);pr intf(" ÛÛÛÛÛÛÛ ÛÛÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛ ÜÛÛÛÛÛÜ ");
    gotoxy(6,14);pr intf("ÛÛÛ ÛÛ ÛÛÛ ÛÛÛÛ ÛÛÛ ÛÛ ÛÛÛ ÛÛ ÛÛÛÛ ÛÛ ÜÛÛÛ ÛÛÛÜ ");
    gotoxy(6,15);pr intf("ÛÛÛÝÜÜ ÛÛ ÛÛÛ ÛÛÛÝÛÛ ÛÛÛÝÛÛ ÛÛÛ ÛÛÛ ÛÛÛ ");
    gotoxy(6,16);pr intf("ÛÛÛÛÛÛ ÛÛ ÛÛÛ ÛÛÛÛÛÛ ÛÛÛÛÛÛ ÛÛÛ ÛÛÛÛÛÛÛÛÛ ");
    gotoxy(6,17);pr intf("ÛÛÛ ÛÛ ÛÛÛ ÛÛÛÛ ÛÛÛ ÛÛ ÛÛÛ ÛÛ ÛÛÛÛ ÛÛ ÛÛÛ ÛÛÛ ");
    gotoxy(6,18);pr intf(" ÛÛÛÛÛÛÛ ÛÛÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛ ÛÛ ");


    // gotoxy(6,20);cp rintf("");
    h=getch();
    gotoxy(23,21);s ystem("pause");
    while(h=='y');
    main();



    getch();
    return 0;
    }

    void menu()
    {
    clrscr();


    gotoxy(5,6);cpr intf( "ÉËÍÍËÍÍËÍÍËÍÍË ÍÍË»");
    gotoxy(5,7);cpr intf( "º EDEECA º");
    gotoxy(5,8);cpr intf( "ÌÍÍÍÍÍÍÍÍÍÍÍÍÍ ÍÍ͹");
    gotoxy(5,9);cpr intf( "º º");
    gotoxy(5,10);cp rintf("º [1] Report º");
    gotoxy(5,11);cp rintf("º º");
    gotoxy(5,12);cp rintf("ÈÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍͼ");

    gotoxy(23,6);cp rintf( "ÉËÍÍËÍÍËÍÍËÍÍË ÍÍË»");
    gotoxy(23,7);cp rintf( "º EDEECA º");
    gotoxy(23,8);cp rintf( "ÌÍÍÍÍÍÍÍÍÍÍÍÍÍ ÍÍ͹");
    gotoxy(23,9);cp rintf( "º º");
    gotoxy(23,10);c printf("º [2] Pay Slip º");
    gotoxy(23,11);c printf("º º");
    gotoxy(23,12);c printf("ÈÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍͼ");

    gotoxy(41,6);cp rintf( "ÉËÍÍËÍÍËÍÍËÍÍË ÍÍË»");
    gotoxy(41,7);cp rintf( "º EDEECA º");
    gotoxy(41,8);cp rintf( "ÌÍÍÍÍÍÍÍÍÍÍÍÍÍ ÍÍ͹");
    gotoxy(41,9);cp rintf( "º º");
    gotoxy(41,10);c printf("º [3] Update º");
    gotoxy(41,11);c printf("º º");
    gotoxy(41,12);c printf("ÈÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍͼ");

    gotoxy(59,6);cp rintf( "ÉËÍÍËÍÍËÍÍËÍÍË ÍÍË»");
    gotoxy(59,7);cp rintf( "º EDEECA º");
    gotoxy(59,8);cp rintf( "ÌÍÍÍÍÍÍÍÍÍÍÍÍÍ ÍÍ͹");
    gotoxy(59,9);cp rintf( "º º");
    gotoxy(59,10);c printf("º [4] Maintenace º");
    gotoxy(59,11);c printf("º º");
    gotoxy(59,12);c printf("ÈÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍͼ");

    gotoxy(32,14);c printf("ÉËÍÍËÍÍ ËÍÍËÍÍËÍÍË»");
    gotoxy(32,15);c printf("º EDEECA º");
    gotoxy(32,16);c printf("ÌÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍ͹");
    gotoxy(32,17);c printf("º º");
    gotoxy(32,18);c printf("º [5] Exit º");
    gotoxy(32,19);c printf("º º");
    gotoxy(32,20);c printf("ÈÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍͼ");



    gotoxy(29,22);c printf("Choice: ");
    scanf("%d",&cho ice);

    switch(choice)
    {
    case 1:{
    report();
    }
    case 2:{
    payslip();
    }
    case 3:{
    update();
    }
    //case 4:{
    // maintenance();
    // }
    case 5:{
    bye();
    }

    // getch();
    }


    void report()
    {

    char timein[5];
    char timeout[5];
    char in_hour[3];
    char out_hour[3];
    char in_min[3];
    char out_min[3];
    float gross_pay;

    char *days[5]={"Monday","Tue sday","Wednesda y","Thursday"," Friday"};

    clrscr();


    read=fopen("ros e.txt","a+");

    for(int day=0;day<5;day ++)
    {
    if(day==0)
    {
    fprintf(read,"% s,",code);

    gotoxy(12,26);c printf("Enter time-in for %s : ",days[0]);
    scanf("%s",&tim ein);
    gotoxy(12,27);c printf("Enter time-out for %s : ",days[0]);
    scanf("%s",&tim eout);
    }
    if(day==1)
    {
    gotoxy(12,29);c printf("Enter time-in for %s : ",days[1]);
    scanf("%s",&tim ein);
    gotoxy(12,30);c printf("Enter time-out for %s : ",days[1]);
    scanf("%s",&tim eout);
    }
    if(day==2)
    {
    gotoxy(12,32);c printf("Enter time-in for %s: ",days[2]);
    scanf("%s",&tim ein);
    gotoxy(12,33);c printf("Enter time-out for %s: ",days[2]);
    scanf("%s",&tim eout);
    }
    if(day==3)
    {
    gotoxy(12,35);c printf("Enter time-in for %s : ",days[3]);
    scanf("%s",&tim ein);
    gotoxy(12,36);c printf("Enter time-out for %s : ",days[3]);
    scanf("%s",&tim eout);
    }
    if(day==4)
    {
    gotoxy(12,38);c printf("Enter time-in for %s : ",days[4]);
    scanf("%s",&tim ein);
    gotoxy(12,39);c printf("Enter time-out for %s : ",days[4]);
    scanf("%s",&tim eout);
    }
    }


    for(int i=0;i<2;i++)

    in_hour[i]=timein[i];
    in_min[i]=timein[i+3];
    out_hour[i]=timeout[i];
    out_min[i]=timeout[i+3];

    float conv_outmin;
    conv_outmin=ato f(out_min);
    if(conv_outmin> 0){
    if(conv_outmin< 15){
    conv_outmin=0;} }

    float conv_inmin,conv _inhour;
    conv_inmin=atof (in_min);
    conv_inhour=ato f(in_hour);
    if(conv_inhour< =7){
    if(conv_inhour> 0){
    conv_inhour=8;}
    conv_inmin=0;}

    float total_timein=0, total_timeout=0 ;
    total_timein=co nv_inhour+conv_ inmin/60;
    total_timeout=a tof(timeout)+co nv_outmin/60;

    float total_time=tota l_timeout-total_timein;

    if(total_time>4 )
    total_time=tota l_time-1;

    hrs=hrs+total_t ime;

    {

    fprintf(read,"% s %s,\n",timein,t imeout);

    }


    gotoxy(12,45);c printf("Total hours present : %.2f",hrs);
    {
    gross_pay=(rate/8)*hrs;
    gotoxy(12,47);c printf("Gross Salary : %.2f",gross_pay );
    gotoxy(12,49);c printf("------------------------------------------------------");
    }



    fclose(read);

    }


    void payslip()
    {
    clrscr();
    if((fp=fopen("e deeca.txt","r") )==NULL)
    {
    cprintf("Error opening student.txt\n") ;
    }
    else
    {
    cprintf("Names int file are: \n\n");
    while(!feof(fp) )
    {
    fflush(stdin);
    fscanf(fp,"%s %s",&lastname,& name);
    fflush(stdin);
    cprintf("\n %s %s\n",lastname, name);
    }
    system("pause") ;
    main();
    }
    }

    void update()
    {
    char up;

    clrscr();
    gotoxy(5,6);cpr intf( "ÉËÍÍËÍÍËÍÍËÍÍË ÍÍË»");
    gotoxy(5,7);cpr intf( "º EDEECA º");
    gotoxy(5,8);cpr intf( "ÌÍÍÍÍÍÍÍÍÍÍÍÍÍ ÍÍ͹");
    gotoxy(5,9);cpr intf( "º º");
    gotoxy(5,10);cp rintf("º [1] Add Data º");
    gotoxy(5,11);cp rintf("º º");
    gotoxy(5,12);cp rintf("ÈÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍͼ");

    gotoxy(23,6);cp rintf( "ÉËÍÍËÍÍËÍÍËÍÍË ÍÍË»");
    gotoxy(23,7);cp rintf( "º EDEECA º");
    gotoxy(23,8);cp rintf( "ÌÍÍÍÍÍÍÍÍÍÍÍÍÍ ÍÍ͹");
    gotoxy(23,9);cp rintf( "º º");
    gotoxy(23,10);c printf("º [2] Edit Data º");
    gotoxy(23,11);c printf("º º");
    gotoxy(23,12);c printf("ÈÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍͼ");

    gotoxy(10,25);p rintf("Enter your choice:");
    scanf("%c",&up) ;

    switch(up)
    {
    case 1:
    // {
    // add();
    // }
    //case 2:
    // {
    // edit();
    // }
    //}
    }

    void add()

    {

    do{


    if((fp=fopen("s tudgie.txt","a+ "))==NULL)

    {
    cprintf("Error opening student.txt\n") ;
    }
    else
    {
    fflush(stdin);
    gotoxy(23,12);c printf("Enter complete name: ");
    fflush(stdin);
    gotoxy(23,14);s canf("%s %s",&lastname,& name);
    gotoxy(23,16);f printf(fp,"%s %s\n",lastname, name);

    fclose(fp);
    }
    gotoxy(23,18);c printf("Add another data?[y/n]");
    h=getch();
    gotoxy(23,21);s ystem("pause");
    }while(h=='y');
    main();
    } }

    //void edit()
    //{






    void bye()
    {
    clrscr();

    gotoxy(24,14);p rintf("ÛÛ ÛÛ ÛÛÛÛÛ ÜÛÛÛÛÛÛÜ ÛÛÛÛÛÛÛÛ ");
    gotoxy(24,15);p rintf("ÛÛÛ ÛÛÛ ÛÛÛ ÛÛÛ ÛÛß ÛÛÛÛ ÛßßßßßÛÛÛ");
    gotoxy(24,16);p rintf("ÛÛÛÛ ÛÛÛÛ ÛÛÛ ÛÛÛ ÛÛ ÜÛÛß ÛÛÛ ");
    gotoxy(24,17);p rintf("ÛÛÛÛÛÛÛÛ Û ÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛÜ ÜÛÛß ");
    gotoxy(24,18);p rintf("ÛÛ ÛÛÛ ÛÛ ÛÛÛ ÛÛÛ ÛÛ ÛÛÛ ÜÛßß Û");
    gotoxy(24,19);p rintf("ÛÛ ß ÛÛ ÛÛ ÛÛ ÛÛ ÛÛÛÜ ÛÛÛÛÛÛÛÛÛ");

    //getch();
    }}
    [/CENTER]
    [/LEFT][/LEFT]
  • marianne rosette bermil
    New Member
    • Sep 2010
    • 2

    #2
    can you please..

    Comment

    • whodgson
      Contributor
      • Jan 2007
      • 542

      #3
      What error, compiling, run time, logic?
      Where is the output unexpected?
      Code:
      Also please enclose your code in code tags like this by selecting and pressing #

      Comment

      Working...