Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

after input, program crashes

$
0
0
#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\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 only");
    printf("\n\t\tto avoid errors");
    printf("\n\n\t\tEmployee No.: ");
    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\tAddress No: ");
    scanf("%d",adresno);
    printf("\n\t\tAddress Street and City: ");
    scanf("%s",adres);
    printf("\n\t\tMonthly payroll: ");
    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 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("\t\tAddress: \n");
       scanf("%s",adres);
       printf("\n\t\tMonthly payroll: ");
       scanf("%d",&pay[1]);
       printf("\n\t\tINFOMATION 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 after i input SSS contribution windows error will pop up saying send or dont send error ,what should i do?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>