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

int InformaticsPayrollSystemMenu();

int main()
{
char fname[100],lname[100],sex[100],con[100],dob[100],ans;
int empnum[100],pay[100],payrollSystemMenuChoice,choice,emp,edit; 
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\t\tNOTE:Please fill up the form properly to avoid errors.");
    printf("\n\n\t\tEmployee No.: ");
    scanf(" %d",&empnum[1]);
    printf("\t\tFirst Name: ");
    scanf(" %s",fname);
    printf("\t\t Last Name: ");
    scanf(" %s",lname);
    printf("\t\t Date of Birth: ");
    scanf(" %s",dob);
    printf("\t\t Sex: ");
    scanf(" %s",sex);
    printf("\t\t Contact No: ");
    scanf(" %s",con);
    printf("\t\t Payroll: ");
    scanf(" %d",&pay[1]);
    printf("\n\t\t INFOMATION 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 employees rate per hour: ");
    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: ");
    scanf(" %f",&ot);
    printf("\n\t\tEnter deduction rate due to absent or etc.: ");
    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 employee is: P%.2f\n",weeksal);
    printf("\n\t\tThe monthly salart of employee is: P%.2f\n",monthsal);
    printf("\n\t\tThe annual salary of employee is: P%.2f\n",annal);    
    printf("\n\t\tMonthly gross salary deducted by tax : P%.2f\n",tax);

    printf("\n\t\tEnter SSS contribution: P");
    scanf(" %d",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 the employee is: P%.2f",netpay); 

}

}

case 2:
{   
    printf("\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\t Enter 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\t Enter Employee Number: ");
    scanf(" %d",&emp);

if(emp == empnum[1])
{
     printf("\n\t\t EMPLOYEE FOUND.");
     printf("\n\t\t Are you sure you want to edit? (Y or N): ");
     scanf(" %c",&ans);

}
else
{
      printf("\n\t\t EMPLOYEE NOT FOUND.");
      i++;
      break;
}
{
if(ans == 'Y' || ans == 'y')
{
       printf("\n\t\tEmployee Number: ");
       scanf(" %d",&empnum[1]);
       printf("\n\t\tFirst Name: ");
       scanf(" %s",fname);
       printf("\n\t\tLast Name: ");
       scanf(" %s",lname);
       printf("\n\t\tDate of Birth: ");
       scanf(" %s",dob);
       printf("\n\t\tSex: ");
       scanf(" %s",sex);
       printf("\n\t\tContact no: ");
       scanf(" %s",con);
       printf("\n\t\tRate/Hour: ");
       scanf(" %d",&pay[1]);
       printf("\n\t\t INFOMATION SUCCESSFULLY EDITED...THANK YOU!!!\n");
       i++;
       break;


}
case 2:
{

      printf("\n\t\t******************************************");
      printf("\n\t\t********** DELETE EMPLOYEE ***************");
      printf("\n\t\t******************************************");
      printf("\n\n\t\t Enter Employee Number: ");
      scanf(" %d",&emp);
if(emp == empnum[1])
{
      printf("\n\t\t EMPLOYEE DATA FOUND.");
      printf("\n\t\t Are you sure you want to delete?? (Y or N): ");
      scanf(" %c",&ans);

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

}

{


}
}

}
}
}
}
}
}

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


int InformaticsPayrollSystemMenu(){
int userChoice;

    printf("\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\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] Exit\n");
    printf("\n\t\t NOTE:Please write the number only,");
    printf("\n\t\t this program is very sensitive,you may encounter matrix codes:)");
    printf("\n\n\t\t Please Enter your choice: ");
    scanf("%d", &userChoice);

    return userChoice;


}

THE PROBLEM IS WHEN I INPUT THE SSS CONTRIBUTION THE PROGRAM WILL STOP BECAUSE OF WINDOWS ERROR WHAT SHOULD I DO?

Member Avatar for laryjose

Use the ampersand (&) for scanf. Like you have done before for other scanf statements. Go through the code and check all your scanf statements

i already check it out,and the code is correct.its not really a program error but its the windows that crashes after putting the input of SSS contribution

No, the code is not correct, and it's not Windows problem. Listen!

You need to add the ampersand for your scanf()'s where the variable is not a pointer (or the name of an array).

printf("\n\t\tEnter SSS contribution: P");
scanf(" %d",sss);             //add an ampersand: &sss
printf("\n\t\tEnter PAG IBIG contribution: P");
scanf(" %f",pagibig);        //add an ampersand: &pagibig
printf("\n\t\tEnter Philhealth contribution: P");
scanf(" %f",phl);            //add an ampersand: &phl

I did not check all your code for problems, or for missing ampersands - you need to do that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.