-1

PROBLEMS
1.AFTER INPUT IN PHILHEALTH CONTRIBUTION PROGRAM CRUSHES.
2.AFTER INPUT Y or y in delete employee data PROGRAM CRUSHES.
3.AFTER REGISTER EMPLOYEE AND GOING TO VIEW EMPLOYEE PROGRAM CRUSHES.
SAME ERROR A WINDOW WILL POP UP AND IT LIKE THE WINDOWS ERROR.

#include <stdio.h>
#include <string.h>

   int InformaticsPayrollSystemMenu();

   int main()
{
   char fname[100],lname[100],sex[100],con[100],dob[100],adres[100],ans;
   int empnum[100],pay[100],payrollSystemMenuChoice,choice,emp,edit,adresno[100]; 
   int i=0,found=0;
   float rate,week,weekyear,ot,abs,weeksal,monthsal,annal,sss,pagibig,phl,tax,netpay;
   system ("color 0A");
   system("title INFORMATICS PAYROLL SYSTEM");

do
{
    payrollSystemMenuChoice = InformaticsPayrollSystemMenu();

switch(payrollSystemMenuChoice)
{
case 1:
{
    found = 1;
    printf("\n\t\t******************************************");
    printf("\n\t\t********* REGISTER NEW EMPLOYEE **********");
    printf("\n\t\t******************************************");
    printf("\n\n\t\tNOTE:Please fill up the form properly and don't use SPACING,");
    printf("\n\t\tif the program ask for NUMBER just input integers");
    printf("\n\t\tto avoid errors");
    printf("\n\n\t\tEmployee No.: ");
    scanf("%d",&empnum[1]);
    printf("\n\t\tFirst Name: ");
    scanf("%s",&fname[100]);
    printf("\n\t\tLast Name: ");
    scanf("%s",&lname[100]);
    printf("\n\t\tDate of birth,Mm-Dd-Yy: ");
    scanf("%s",&dob[100]);
    printf("\n\t\tSex: ");
    scanf("%s",&sex[100]);
    printf("\n\t\tContact No: ");
    scanf("%s",&con[100]);
    printf("\n\t\tAddress No: ");
    scanf("%d",&adresno[1]);
    printf("\n\t\tAddress Street and City: ");
    scanf("%s",&adres[100]);
    printf("\n\t\tMonthly payroll: P ");
    scanf("%d",&pay[1]);
    printf("\n\n\t\tINFOMATION HAS BEEN SAVED...THANK YOU!!!");
    i++;
    getch();
    break;

case 3:
{
    printf("\n\t\t******************************************");
    printf("\n\t\t************ CREATE PAYROLL **************");
    printf("\n\t\t******************************************");
    printf("\n\n\t\tEnter employee number: ");
    scanf("%f",&empnum[1]);
    printf("\n\n\t\tEnter employee rate per hour: P ");
    scanf("%f",&rate);
    printf("\n\t\tEnter number of hours he/she works each week: ");
    scanf("%f",&week);
    printf("\n\t\tEnter number of weeks he/she works per year: ");
    scanf("%f",&weekyear);
    printf("\n\t\tEnter overall overtime rate: P ");
    scanf("%f",&ot);
    printf("\n\t\tEnter deduction rate due to absent or etc.: P ");
    scanf("%f",&abs);

    weeksal=rate*week-abs;
    monthsal=weeksal*4+ot-abs;
    annal=weeksal*weekyear;
    tax=monthsal*0.12;
    netpay=tax-sss-pagibig-phl;

    printf("\n\t\tNOTE:Base on Gross Salary,not yet deducted.\n");
    printf("\n\t\tThe weekly salary of %s,%s is: P %.2f\n",lname,fname,weeksal);
    printf("\n\t\tThe monthly salart of this employee is: P %.2f\n",monthsal);
    printf("\n\t\tThe annual salary of this employee is: P %.2f\n",annal);    
    printf("\n\t\tMonthly gross salary already deducted by tax : P %.2f\n",tax);

    printf("\n\t\tEnter SSS contribution: P ");
    scanf("%f",&sss);
    printf("\n\t\tEnter PAG IBIG contribution: P ");
    scanf("%f",&pagibig);
    printf("\n\t\tEnter Philhealth contribution: P ");
    scanf("%f",&phl);
    printf("\n\t\tThe total Netpay of %s,%s is: P %.2f",lname[100],fname[100],netpay); 
    getch();
    break;


}
case 4:
{

    printf("\n\t\t******************************************");
    printf("\n\t\t************ VIEW EMPLOYEE DATA **********");
    printf("\n\t\t******************************************");     
    printf("\n\n\t\tEmployee No.: %d",empnum[1]);
    printf("\n\t\tFirst Name: %s",fname[100]);
    printf("\n\t\tLast Name: %s",lname[100]);
    printf("\n\t\tDate of birth,Mm-Dd-Yy: %s",dob[100]);
    printf("\n\t\tSex: %s",sex[100]);
    printf("\n\t\tContact No: %s",con[100]);
    printf("\n\t\tAddress No: %d",adresno[1]);
    printf("\n\t\tAddress Street and City: %s",adres[100]);
    printf("\n\t\tMonthly payroll: P %d",pay[1]);




}

}

case 2:
{   
    printf("\n\n\t\t******************************************");
    printf("\n\t\t************ MANAGE EMPLOYEES ************");
    printf("\n\t\t******************************************");
    printf("\n\n\t\t[1] Update/Edit Employee\n");
    printf("\t\t[2] Delete Employee\n");
    printf("\t\t[3] Back to Main Menu\n");
    printf("\n\t\tEnter your choice: ");
    scanf("%d",&choice);
switch(choice)
{

case 1:
{
    printf("\n\t\t******************************************");
    printf("\n\t\t********** UPDATE/EDIT EMPLOYEE **********");
    printf("\n\t\t******************************************");
    printf("\n\n\t\tEnter Employee Number: ");
    scanf("%d",&emp);

if(emp == empnum[1])
{
     printf("\n\t\tEMPLOYEE DATA FOUND.");
     printf("\n\n\t\tAre you sure you want to edit his/her data? (Y or N): ");
     scanf(" %c",&ans);


}

else
{
      printf("\n\t\tEMPLOYEE NOT FOUND.");
      printf("\n\n\t\tReason:Maybe you do not have yet register this employee,");
      printf("\n\t\tor edited his/her data.");
      i++;
      break;
}
{
if(ans == 'Y' || ans == 'y')
{
       printf("\n\t\tEmployee Number: ");
       scanf("%d",&empnum[1]);
       printf("\n\t\tFirst Name: ");
       scanf("%s",&fname[100]);
       printf("\n\t\tLast Name: ");
       scanf("%s",&lname[100]);
       printf("\n\t\tDate of Birth: ");
       scanf("%s",&dob[100]);
       printf("\n\t\tSex: ");
       scanf("%s",&sex[100]);
       printf("\n\t\tContact no: ");
       scanf("%s",&con[100]);
       printf("\t\tAddress: \n");
       scanf("%s",&adres[100]);
       printf("\n\t\tMonthly payroll: ");
       scanf("%d",&pay[1]);
       printf("\n\t\tINFOMATION SUCCESSFULLY EDITED...THANK YOU!!!\n");
       i++;
       break;


}
if(ans == 'n' || ans == 'N')
{
       i++;
       break;
}
case 2:
{     
      printf("\n\t\t******************************************");
      printf("\n\t\t********** DELETE EMPLOYEE ***************");
      printf("\n\t\t******************************************");
      printf("\n\n\t\tEnter Employee Number: ");
      scanf("%d",&emp);

if(emp == empnum[1])
{
      printf("\n\t\tEMPLOYEE DATA FOUND.");
      printf("\n\n\t\tAre you sure you want to delete his/her data? (Y or N): ");
      scanf(" %c",&ans);

}
else
{
      printf("\n\t\tEMPLOYEE NOT FOUND.");
      i++;
      break;
}
if(ans == 'Y' || ans == 'y')
{
      printf("\n\t\t%d %s,%s data has been successfully DELETED.",empnum[1],lname[100],fname[100]);
      i++;
      break;


}
if(ans == 'n' || ans == 'N')
{

      i++;
      getch();
      break;


}

{


}
}

}
}
}
}
}
}

while(payrollSystemMenuChoice != 5);
return 0;
}


int InformaticsPayrollSystemMenu(){
int userChoice;

    printf("\n\n\t\t******************************************");
    printf("\n\t\t*******    I N F O R M A T I C S    ******");
    printf("\n\t\t******* P A Y R O L L   S Y S T E M ******");
    printf("\n\t\t******************************************");
    printf("\n\n\t\tNOTE:Please write the number only,");
    printf("\n\t\tthis program is very sensitive,you may encounter matrix codes:)");
    printf("\n\n\t\t[1] Register New Employees/Staff\n");
    printf("\t\t[2] Manage Employees/Staff\n");
    printf("\t\t[3] Create Payroll \n");
    printf("\t\t[4] View Employees \n");
    printf("\t\t[5] Exit\n");
    printf("\n\n\t\tPlease Enter your choice: ");
    scanf("%d", &userChoice);

    return userChoice;


}
Votes + Comments
Double post of: [http://www.daniweb.com/software-development/c/threads/447368/i-need-some-help-guys..asap-thanks] I don't want to pollute the thread with a post about this, so my comment ends up here.
2
Contributors
1
Reply
10
Views
4 Years
Discussion Span
Last Post by Ancient Dragon
0

I didn't read your whole program, but all the scanf() starting on line 33 are wrong
scanf("%s",&fname[100]);

That is passing a pointer to the last element of the fname array. It should be passing a pointer to the first element, like this:
scanf("%s",fname);

Notice it is not necessary to use the & pointer operator because arrays are always passed as pointers. For an array of any type just use the name of the array and it will get passed as a pointer to the first element of the array. Only for non-arrays such as an int do you use the & pointer operator.

You need to make similar corrections throughout the program.

Edited by Ancient Dragon

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.