Hello, good afternoon. :)
Now I got some problems with my "Create Payroll". I changed the "rate[100]" integer to "salrate[100]" float. After changing these errors prompted me.
Errors:
payroll system.cpp(157,22): Illegal use of pointer <-- This is "Error"
payroll system.cpp(158,8): Possible use of 'gsalary' before definition <-- This is "Warning"
I don't know what are the errors all about. I need some explanations with this and what should I do in order to solve this problem.
Here's the whole codes:
#include <stdio.h>
#include <conio.h>
#include <string.h>
int payroll_system_menu();
int main()
{
char fname[100][100],lname[100][100],sex[100][100],address[100][100],dob[100][100];
char *day[5]={"Monday","Tuesday","Wednesday","Thursday","Friday"};
int empno[100];
int i=0,j=0,f=0,found=0;
int srchemp,payemp,payrollmenu;
float timeinhour[5],timeinminute[5],timeouthour[5],timeoutminute[5];
float totalhour,totalmin,workhour;
float sss,cashad,others,gsalary,salary,tax,deductions;
float salrate[100];
totalhour = 0;
totalmin = 0;
do
{
payrollmenu = payroll_system_menu();
if(payrollmenu == 1)
{
clrscr();
printf("\n\t\t******************************************");
printf("\n\t\t********* REGISTER NEW EMPLOYEE **********");
printf("\n\t\t******************************************");
printf("\n\n\t\t Employee No.: ");
scanf("%d",&empno[i]);
printf("\t\t First Name: ");
scanf("%s",&fname[j]);
printf("\t\t Last Name: ");
scanf("%s",&lname[j]);
printf("\t\t Date of Birth: ");
scanf("%s",&dob[j]);
printf("\t\t Sex: ");
scanf("%s",&sex[j]);
printf("\t\t Address: ");
scanf("%s",&address[j]);
printf("\t\t Rate/Hour: ");
scanf("%f",&salrate[i]);
printf("\n\t\t INFORMATION HAS BEEN SAVED. THANK YOU!!!");
i++;
j++;
getch();
}
if(payrollmenu == 2)
{
clrscr();
printf("\n\t\t******************************************");
printf("\n\t\t************ SEARCH EMPLOYEES ************");
printf("\n\t\t******************************************");
printf("\n\n\t\t Enter Employee Number: ");
scanf("%d",&srchemp);
for(i=0;i<=100;i++)
{
if(empno[i]==srchemp)
{
found=1;
break;
}
else
{
found = 0;
}
}
if(found==1)
{
printf("\n\t\t EMPLOYEE %d FOUND!\n",srchemp);
}
if(found==0)
{
printf("\n\t\t EMPLOYEE %d NOT FOUND!",srchemp);
}
getch();
}
if(payrollmenu == 3)
{
clrscr();
printf("\n\t\t******************************************");
printf("\n\t\t************ CREATE PAYROLL **************");
printf("\n\t\t******************************************");
printf("\n\n\t\t Enter Employee Number: ");
scanf("%d",&payemp);
for(i=0;i<=100;i++)
{
if(empno[i]==payemp)
{
found = 1;
break;
}
else
{
found = 0;
}
}
if(found == 1)
{
printf("\n\t\t EMPLOYEE %d FOUND!\n",payemp);
while(f<=4)
{
printf("\n\t\t Time In for %s: ",day[f]);
scanf("%f:%f",&timeinhour[f],&timeinminute[f]);
if((timeinhour[f]>=8) && (timeinhour[f]<12))
{
if(timeinhour[f]>8)
{
totalhour = totalhour + (timeinhour[f] - 8);
totalmin = totalmin + timeinminute[f];
}
if((timeinhour[f]==8) && (timeinminute[f]>0))
{
totalmin = totalmin + timeinminute[f];
}
}
if(timeinhour[f]>=12)
{
totalhour = totalhour + 4;
if(timeinhour[f]==13)
{
totalmin = totalmin + timeinminute[f];
}
if(timeinhour[f]>13)
{
totalhour = totalhour + (timeinhour[f] - 13);
totalmin = totalmin + timeinminute[f];
}
}
printf("\t\t Time Out for %s: ",day[f]);
scanf("%f:%f",&timeouthour[f],&timeoutminute[f]);
if(timeouthour[f]<=16)
{
if(timeouthour[f]<16)
{
totalhour = totalhour + (16 - timeouthour[f]);
totalmin = totalmin + (60 - timeoutminute[f]);
}
if(timeouthour[f]==16)
{
totalmin = totalmin + (60 - timeoutminute[f]);
}
}
f++;
printf("\t\t------------------------------------------");
}
printf("\n\t\t DEDUCTIONS:");
printf("\n\t\t SSS: ");
scanf("%f",&sss);
printf("\t\t Cash Advance: ");
scanf("%f",&cashad);
printf("\t\t Tax: ");
scanf("%f",&tax);
printf("\t\t Others: ");
scanf("%f",&others);
workhour = 40 - (totalhour + totalmin/60);
gsalary = salrate * workhour;
tax = gsalary * 0.010;
deductions = sss + cashad + tax + others;
salary = gsalary - deductions;
printf("\n\t\t------------------------------------------\n");
printf("\n\t\t| PAYROLL |\n");
printf("\n\t\t------------------------------------------\n");
printf("\t\tName : %s %s\n",fname,lname);
printf("\t\tNo. of hours worked : %f\n",workhour);
printf("\t\tGross Salary : %f\n",gsalary);
printf("\t\tNet Salary : %f\n",salary);
printf("\t\t------------------------------------------\n");
}
if(found == 0)
{
printf("\n\t\t EMPLOYEE %d NOT FOUND!\n",payemp);
}
getch();
}
}while(payrollmenu != 4);
return 0;
}
int payroll_system_menu()
{
int cho;
clrscr();
printf("\n\t\t******************************************");
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\n");
printf("\t\t [2] Search Employees\n");
printf("\t\t [3] Create Payroll\n");
printf("\t\t [4] Exit\n");
printf("\n\t\t Enter your choice: ");
scanf("%d",&cho);
return cho;
}
Hope you guys can help me with this. Thanks! :)