hi i am kind of new to programming, i have managed to create a simple payroll database in C++, but now i am trying to convert in into C but i am keep getting error, can anyone help me convert this code to C. I really need this so thatr i can learn my mistakes in C. Below is the C++ code that i have have developed.
Thank you,
Sep 25 '07
14 2450 RRick 463
Recognized Expert Contributor
The above fprintf format statement assumes that the last two values are integers. If they are doubles, use "%lf" instead of "%d".
Hi I am sorry for not updating my progress for the past 2 weeks, i have tried all those ideas given but i am having errors (almost 300), please someone help me translate the whole coding for me, i am feel very bad for requesting this, but i cant do it its really hard for me as i am still new, please someone help me i will need this to as a reference for my studies.
sicarie 4,677
Recognized Expert Moderator Specialist
Sorry dude, nobody here can (see our Posting Guidelines) or will (because it's your assignment) do your work for you. If you post the errors you are having trouble with, we can point you in the right direction. Or if you post a generic error, we can show you how to break it down (usually there is a line number around which the issue is - or something on that line caused the issue because it was instantiated/modified improperly, etc..), but we won't do it for you.
Also, cutting and pasting errors into Google usually will return someone who has had the same issue as you...
I have develop a new coding using C, with some problem where the search and update functions are working but when I enter a record which is not available it getting me to another record, my delete module also is notworking properly, and how to make my time tick. Below is my coding, thankyou for any help. - #include<stdio.h>
-
#include<stdlib.h>
-
#include<conio.h>
-
#include<ctype.h>
-
#include<string.h>
-
#include <time.h>
-
void ins(void);
-
void oldf(void);
-
void newf(void);
-
void add(void);
-
void search(void);
-
void upd(void);
-
void del(void);
-
struct payroll
-
{ char no[5];
-
char name[25];
-
double salary;
-
double rate;
-
double net;
-
} payroll_rec;
-
-
void main()
-
{
-
char i;
-
time_t now;
-
time(&now);
-
-
-
do
-
{
-
system("cls");
-
-
printf("\n\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\7");
-
printf("\n\n Welcome to Optimum Technologies' Payroll Department\t\t\t\t\t %.24s.\n",ctime(&now));
-
printf("\t\t Main Menu\n\n");
-
printf("\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\n");
-
printf("\nWhat do you wish to do?\n");
-
printf("-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n\n");
-
printf("1. Insert Employee Record And Compute Weekly Pay\n");
-
printf("2. Display All Records\n");
-
printf("3. Compute Monthly Pay Slip\n");
-
printf("4. Add Employee Record\n");
-
printf("5. Search and View Record\n");
-
printf("6. Update Record\n");
-
printf("7. Delete Record\n");
-
printf("8. Exit\n");
-
printf("\n-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
-
printf("You choose number :");
-
i=getche();
-
-
switch(tolower(i))
-
{
-
case '1': ins(); break;
-
case '2': oldf(); break;
-
case '3': newf(); break;
-
case '4': add(); break;
-
case '5': search(); break;
-
case '6': upd(); break;
-
case '7': del(); break;
-
case '8': printf("\7\n\tPlease any key to exit...");
-
getch();
-
exit(0);
-
break;
-
default : printf("\n\tChoice error ! Please try again.");
-
getch();
-
}
-
}while(i!='7');
-
-
}
-
-
void ins(void)
-
{
-
FILE *fp;
-
if((fp=fopen("payroll.txt","wb"))==NULL)
-
{
-
printf("Error in opening file");
-
exit(1);
-
}
-
struct payroll
-
{
-
char no[5];
-
char name[25];
-
double salary;
-
double rate;
-
double net;
-
} payroll_rec;
-
char numstr[50];
-
system("cls");
-
printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
-
printf("\n Insert Employee Record And Compute Weekly Pay Module\n");
-
printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3");
-
do
-
{
-
-
printf("\n\nEnter Employee No : ");
-
gets(payroll_rec.no);
-
printf("Enter Employee Name : ");
-
gets(payroll_rec.name);
-
printf("Enter Hours Worked Per Week : ");
-
payroll_rec.salary=atof(gets(numstr));
-
printf("Enter Hourly Wage : ");
-
payroll_rec.rate=atof(gets(numstr));
-
payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
-
printf("Your Weekly Pay is RM %.2f\n", payroll_rec.net);
-
fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
-
printf("Add another person(y/n)? :");
-
}
-
while(tolower(getche())=='y');
-
fclose(fp);
-
printf("\nPress any key to return to main menu");
-
getch();
-
}
-
-
void oldf(void)
-
{
-
FILE *fp;
-
if((fp=fopen("payroll.txt","rb"))==NULL)
-
{
-
printf("Error in open file");
-
printf("\007");
-
getch(); exit(1);
-
} system("cls");
-
printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
-
printf("\n\t\t\t Display Record Module\n ");
-
printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
-
printf("\n\n**********************************************************************\n");
-
printf(" Employee ID Employee Name Hours Worked Hourly Wage Weekly Pay\n");
-
printf("***********************************************************************\n");
-
while(fread(&payroll_rec,sizeof(payroll_rec),1,fp)==1)
-
{
-
printf(" %s\t\t%s\t\t%.2f\t%.2f\t\t%.2f\t\t\n",payroll_rec.no,payroll_rec.name,payroll_rec.salary,payroll_rec.rate,payroll_rec.net);
-
-
}
-
fclose(fp);
-
printf("Press any key to return to main menu\n");
-
getch();
-
}
-
-
void newf(void)
-
{
-
double net;
-
double total;
-
FILE *fp;
-
if((fp=fopen("payroll.txt","rb"))==NULL)
-
{
-
printf("Error in open file");
-
printf("\007");
-
getch(); exit(1);
-
} system("cls");
-
printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
-
printf("\n\t\t Compute Monthly Pay Slip Module\n");
-
printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
-
while(fread(&payroll_rec,sizeof(payroll_rec),1,fp)==1)
-
{
-
-
net=payroll_rec.salary*payroll_rec.rate*4;
-
total=payroll_rec.salary*4;
-
printf("\n\n||======================================================================||\n");
-
printf("||\t\t\tOptimum Technologies Pay Vaucher ||\n");
-
printf("|| ||\n");
-
printf("||Employee Name : %s\t\t\t\t\t\t||\n",payroll_rec.name);
-
printf("||Empolyee ID : %s\t\t\t\t\t\t\t||\n",payroll_rec.no);
-
printf("||Hours Worked : %.2f\t\t\t\t\t\t\t||\n",total);
-
printf("||Hourly Wage : RM %.2f\t\t\t\t\t\t\t||",payroll_rec.rate);
-
printf("||Net Salary : RM %.2f\t\t\t\t\t\t||\n",net);
-
printf("|| ||\n");
-
printf("||This is a digitally signed voucher it does not require signature\t||\n");
-
printf("|| ||\n");
-
printf("||======================================================================||\n");
-
}
-
fclose(fp);
-
printf("Press any key to return to main menu");
-
getch();
-
}
-
-
void add(void)
-
{
-
FILE *fp;
-
if((fp=fopen("payroll.txt","ab"))==NULL)
-
{
-
printf("Error in open file");
-
printf("\007");
-
getch(); exit(1);
-
}
-
char str[10];
-
system("cls");
-
printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
-
printf("\n\t\t Add Record Module\n ");
-
printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
-
do{
-
printf("\nEnter Employee No :");
-
gets(payroll_rec.no);
-
printf("Enter Employee Name :");
-
gets(payroll_rec.name);
-
printf("Enter Hours Worked Per Week :");
-
payroll_rec.salary=atof(gets(str));
-
printf("Enter Hourly Wage:");
-
payroll_rec.rate=atof(gets(str));
-
payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
-
printf("Your Weekly Pay is RM %.2f\n", payroll_rec.net);
-
fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
-
printf("Add another person(y/n)? :");
-
} while(tolower(getche())=='y');
-
fclose(fp);
-
-
}
-
-
-
void search(void)
-
{
-
FILE *fp;
-
int i=0;
-
int rec;
-
char ch;
-
int offset;
-
system("cls");
-
printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
-
printf("\n\t\t Serach and View Record Module\n");
-
printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
-
-
if((fp=fopen("payroll.txt","rb"))==NULL)
-
{
-
printf("\nError in open file");
-
printf("\007");
-
getch();
-
exit(1);
-
}
-
do
-
{
-
printf("\n\nEnter record number to search :");
-
scanf("%d",&rec); ch=getchar();
-
offset=(rec-1)*sizeof(payroll_rec);
-
if(fseek(fp,offset,0)!=0)
-
{
-
printf("Can't not find.\n");
-
getch();
-
exit(1);
-
-
}
-
fread(&payroll_rec,sizeof(payroll_rec),1,fp);
-
printf("\nEmployee ID : %s\n",payroll_rec.no);
-
printf("Employee Name : %s\n",payroll_rec.name);
-
printf("Hours Worked : %.2f\n",payroll_rec.salary);
-
printf("Hourly Wage : %.2f\n",payroll_rec.rate);
-
printf("Weekly Salary : %.2f\n",payroll_rec.net);
-
printf("Do you wish to continue(y/n)? :");
-
-
-
}
-
while(tolower(getche())=='y');
-
fclose(fp);
-
printf("\nPress any key to return to main menu");
-
getch();
-
}
-
-
-
void upd(void)
-
{
-
FILE *fp;
-
int i=0;
-
int rec;
-
char ch,str[20];
-
char id[5];
-
int offset;
-
system("cls");
-
printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
-
printf("\n\t\t Update Record Module\n");
-
printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
-
-
if((fp=fopen("payroll.txt","rb"))==NULL)
-
{
-
printf("\nError in open file");
-
printf("\007");
-
getch(); exit(1);
-
}
-
-
printf("\nEnter record number :");
-
scanf("%d",&rec); ch=getchar();
-
offset=(rec-1)*sizeof(payroll_rec);
-
if(fseek(fp,offset,0)!=0)
-
{
-
printf("Can't not find.\n");
-
getch();
-
exit(1);
-
}
-
fread(&payroll_rec,sizeof(payroll_rec),1,fp);
-
strcpy(id,payroll_rec.no);
-
getch();
-
fp=fopen("payroll.txt","r+b");
-
offset=(rec-1)*sizeof(payroll_rec);
-
if(fseek(fp,offset,0)!=0)
-
{
-
printf("Can't not find.\n");
-
getch();
-
exit(1);
-
}
-
printf("\nEnter Employee ID :%s\n",id);
-
strcpy(payroll_rec.no,id);
-
printf("Enter Employee Name :");
-
gets(payroll_rec.name);
-
printf("Enter Hours Worked :");
-
payroll_rec.salary=atof(gets(str));
-
printf("Enter Hourly Wage:");
-
payroll_rec.rate=atof(gets(str));
-
payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
-
fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
-
-
fclose(fp);
-
printf("Press any key to return to main menu");
-
}
-
-
void del(void)
-
{
-
FILE*fp;
-
int i=0;
-
char ans;
-
char rec[7];
-
system("cls");
-
printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
-
printf("\n\t\t Delete Record Module\n ");
-
printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
-
if((fp=fopen("payroll.txt","rb+"))==NULL)
-
{
-
printf("Error in open file");
-
printf("\007");
-
getch();
-
exit(1);
-
}
-
printf("\n\nThis is data for delete\n");
-
do{
-
while(1){
-
fread(&payroll_rec,sizeof(payroll_rec),1,fp);
-
if(ferror(fp)){
-
printf("\nError read of delete file");
-
getch(); exit(1); }
-
if(feof(fp))
-
break;
-
++i;
-
printf("%d. %s\t\t",i,payroll_rec.no);
-
}
-
printf("\nDo you want to delete data(y or n) :");
-
ans=getche();
-
if(ans=='y') {
-
printf("\nEnter record number :");
-
gets(rec);
-
fseek(fp,((atoi(rec)-1)*sizeof(payroll_rec)),SEEK_SET);
-
strcpy(payroll_rec.no,"\0");
-
strcpy(payroll_rec.name,"\0");
-
payroll_rec.salary=NULL;
-
payroll_rec.rate=NULL;
-
payroll_rec.net=NULL;
-
fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
-
if(ferror(fp)) {
-
printf("Error for delete data\n");
-
getch();
-
exit(1);
-
}
-
printf("Delete data complete\n");
-
}
-
printf("\nContinue(press c) or Exit(press e) :");
-
ans=getche();
-
printf("\n");
-
}while(ans!='e');
-
fclose(fp);
I have develop a new coding using C, with some problem where the search and update functions are working but when I enter a record which is not available it getting me to another record, my delete module also is notworking properly, and how to make my time tick. Below is my coding, thankyou for any help. - #include<stdio.h>
-
#include<stdlib.h>
-
#include<conio.h>
-
#include<ctype.h>
-
#include<string.h>
-
#include <time.h>
-
void ins(void);
-
void oldf(void);
-
void newf(void);
-
void add(void);
-
void search(void);
-
void upd(void);
-
void del(void);
-
struct payroll
-
{ char no[5];
-
char name[25];
-
double salary;
-
double rate;
-
double net;
-
} payroll_rec;
-
-
void main()
-
{
-
char i;
-
time_t now;
-
time(&now);
-
-
-
do
-
{
-
system("cls");
-
-
printf("\n\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\7");
-
printf("\n\n Welcome to Optimum Technologies' Payroll Department\t\t\t\t\t %.24s.\n",ctime(&now));
-
printf("\t\t Main Menu\n\n");
-
printf("\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\n");
-
printf("\nWhat do you wish to do?\n");
-
printf("-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n\n");
-
printf("1. Insert Employee Record And Compute Weekly Pay\n");
-
printf("2. Display All Records\n");
-
printf("3. Compute Monthly Pay Slip\n");
-
printf("4. Add Employee Record\n");
-
printf("5. Search and View Record\n");
-
printf("6. Update Record\n");
-
printf("7. Delete Record\n");
-
printf("8. Exit\n");
-
printf("\n-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
-
printf("You choose number :");
-
i=getche();
-
-
switch(tolower(i))
-
{
-
case '1': ins(); break;
-
case '2': oldf(); break;
-
case '3': newf(); break;
-
case '4': add(); break;
-
case '5': search(); break;
-
case '6': upd(); break;
-
case '7': del(); break;
-
case '8': printf("\7\n\tPlease any key to exit...");
-
getch();
-
exit(0);
-
break;
-
default : printf("\n\tChoice error ! Please try again.");
-
getch();
-
}
-
}while(i!='7');
-
-
}
-
-
void ins(void)
-
{
-
FILE *fp;
-
if((fp=fopen("payroll.txt","wb"))==NULL)
-
{
-
printf("Error in opening file");
-
exit(1);
-
}
-
struct payroll
-
{
-
char no[5];
-
char name[25];
-
double salary;
-
double rate;
-
double net;
-
} payroll_rec;
-
char numstr[50];
-
system("cls");
-
printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
-
printf("\n Insert Employee Record And Compute Weekly Pay Module\n");
-
printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3");
-
do
-
{
-
-
printf("\n\nEnter Employee No : ");
-
gets(payroll_rec.no);
-
printf("Enter Employee Name : ");
-
gets(payroll_rec.name);
-
printf("Enter Hours Worked Per Week : ");
-
payroll_rec.salary=atof(gets(numstr));
-
printf("Enter Hourly Wage : ");
-
payroll_rec.rate=atof(gets(numstr));
-
payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
-
printf("Your Weekly Pay is RM %.2f\n", payroll_rec.net);
-
fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
-
printf("Add another person(y/n)? :");
-
}
-
while(tolower(getche())=='y');
-
fclose(fp);
-
printf("\nPress any key to return to main menu");
-
getch();
-
}
-
-
void oldf(void)
-
{
-
FILE *fp;
-
if((fp=fopen("payroll.txt","rb"))==NULL)
-
{
-
printf("Error in open file");
-
printf("\007");
-
getch(); exit(1);
-
} system("cls");
-
printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
-
printf("\n\t\t\t Display Record Module\n ");
-
printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
-
printf("\n\n**********************************************************************\n");
-
printf(" Employee ID Employee Name Hours Worked Hourly Wage Weekly Pay\n");
-
printf("***********************************************************************\n");
-
while(fread(&payroll_rec,sizeof(payroll_rec),1,fp)==1)
-
{
-
printf(" %s\t\t%s\t\t%.2f\t%.2f\t\t%.2f\t\t\n",payroll_rec.no,payroll_rec.name,payroll_rec.salary,payroll_rec.rate,payroll_rec.net);
-
-
}
-
fclose(fp);
-
printf("Press any key to return to main menu\n");
-
getch();
-
}
-
-
void newf(void)
-
{
-
double net;
-
double total;
-
FILE *fp;
-
if((fp=fopen("payroll.txt","rb"))==NULL)
-
{
-
printf("Error in open file");
-
printf("\007");
-
getch(); exit(1);
-
} system("cls");
-
printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
-
printf("\n\t\t Compute Monthly Pay Slip Module\n");
-
printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
-
while(fread(&payroll_rec,sizeof(payroll_rec),1,fp)==1)
-
{
-
-
net=payroll_rec.salary*payroll_rec.rate*4;
-
total=payroll_rec.salary*4;
-
printf("\n\n||======================================================================||\n");
-
printf("||\t\t\tOptimum Technologies Pay Vaucher ||\n");
-
printf("|| ||\n");
-
printf("||Employee Name : %s\t\t\t\t\t\t||\n",payroll_rec.name);
-
printf("||Empolyee ID : %s\t\t\t\t\t\t\t||\n",payroll_rec.no);
-
printf("||Hours Worked : %.2f\t\t\t\t\t\t\t||\n",total);
-
printf("||Hourly Wage : RM %.2f\t\t\t\t\t\t\t||",payroll_rec.rate);
-
printf("||Net Salary : RM %.2f\t\t\t\t\t\t||\n",net);
-
printf("|| ||\n");
-
printf("||This is a digitally signed voucher it does not require signature\t||\n");
-
printf("|| ||\n");
-
printf("||======================================================================||\n");
-
}
-
fclose(fp);
-
printf("Press any key to return to main menu");
-
getch();
-
}
-
-
void add(void)
-
{
-
FILE *fp;
-
if((fp=fopen("payroll.txt","ab"))==NULL)
-
{
-
printf("Error in open file");
-
printf("\007");
-
getch(); exit(1);
-
}
-
char str[10];
-
system("cls");
-
printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
-
printf("\n\t\t Add Record Module\n ");
-
printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
-
do{
-
printf("\nEnter Employee No :");
-
gets(payroll_rec.no);
-
printf("Enter Employee Name :");
-
gets(payroll_rec.name);
-
printf("Enter Hours Worked Per Week :");
-
payroll_rec.salary=atof(gets(str));
-
printf("Enter Hourly Wage:");
-
payroll_rec.rate=atof(gets(str));
-
payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
-
printf("Your Weekly Pay is RM %.2f\n", payroll_rec.net);
-
fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
-
printf("Add another person(y/n)? :");
-
} while(tolower(getche())=='y');
-
fclose(fp);
-
-
}
-
-
-
void search(void)
-
{
-
FILE *fp;
-
int i=0;
-
int rec;
-
char ch;
-
int offset;
-
system("cls");
-
printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
-
printf("\n\t\t Serach and View Record Module\n");
-
printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
-
-
if((fp=fopen("payroll.txt","rb"))==NULL)
-
{
-
printf("\nError in open file");
-
printf("\007");
-
getch();
-
exit(1);
-
}
-
do
-
{
-
printf("\n\nEnter record number to search :");
-
scanf("%d",&rec); ch=getchar();
-
offset=(rec-1)*sizeof(payroll_rec);
-
if(fseek(fp,offset,0)!=0)
-
{
-
printf("Can't not find.\n");
-
getch();
-
exit(1);
-
-
}
-
fread(&payroll_rec,sizeof(payroll_rec),1,fp);
-
printf("\nEmployee ID : %s\n",payroll_rec.no);
-
printf("Employee Name : %s\n",payroll_rec.name);
-
printf("Hours Worked : %.2f\n",payroll_rec.salary);
-
printf("Hourly Wage : %.2f\n",payroll_rec.rate);
-
printf("Weekly Salary : %.2f\n",payroll_rec.net);
-
printf("Do you wish to continue(y/n)? :");
-
-
-
}
-
while(tolower(getche())=='y');
-
fclose(fp);
-
printf("\nPress any key to return to main menu");
-
getch();
-
}
-
-
-
void upd(void)
-
{
-
FILE *fp;
-
int i=0;
-
int rec;
-
char ch,str[20];
-
char id[5];
-
int offset;
-
system("cls");
-
printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
-
printf("\n\t\t Update Record Module\n");
-
printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
-
-
if((fp=fopen("payroll.txt","rb"))==NULL)
-
{
-
printf("\nError in open file");
-
printf("\007");
-
getch(); exit(1);
-
}
-
-
printf("\nEnter record number :");
-
scanf("%d",&rec); ch=getchar();
-
offset=(rec-1)*sizeof(payroll_rec);
-
if(fseek(fp,offset,0)!=0)
-
{
-
printf("Can't not find.\n");
-
getch();
-
exit(1);
-
}
-
fread(&payroll_rec,sizeof(payroll_rec),1,fp);
-
strcpy(id,payroll_rec.no);
-
getch();
-
fp=fopen("payroll.txt","r+b");
-
offset=(rec-1)*sizeof(payroll_rec);
-
if(fseek(fp,offset,0)!=0)
-
{
-
printf("Can't not find.\n");
-
getch();
-
exit(1);
-
}
-
printf("\nEnter Employee ID :%s\n",id);
-
strcpy(payroll_rec.no,id);
-
printf("Enter Employee Name :");
-
gets(payroll_rec.name);
-
printf("Enter Hours Worked :");
-
payroll_rec.salary=atof(gets(str));
-
printf("Enter Hourly Wage:");
-
payroll_rec.rate=atof(gets(str));
-
payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
-
fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
-
-
fclose(fp);
-
printf("Press any key to return to main menu");
-
}
-
-
void del(void)
-
{
-
FILE*fp;
-
int i=0;
-
char ans;
-
char rec[7];
-
system("cls");
-
printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
-
printf("\n\t\t Delete Record Module\n ");
-
printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
-
if((fp=fopen("payroll.txt","rb+"))==NULL)
-
{
-
printf("Error in open file");
-
printf("\007");
-
getch();
-
exit(1);
-
}
-
printf("\n\nThis is data for delete\n");
-
do{
-
while(1){
-
fread(&payroll_rec,sizeof(payroll_rec),1,fp);
-
if(ferror(fp)){
-
printf("\nError read of delete file");
-
getch(); exit(1); }
-
if(feof(fp))
-
break;
-
++i;
-
printf("%d. %s\t\t",i,payroll_rec.no);
-
}
-
printf("\nDo you want to delete data(y or n) :");
-
ans=getche();
-
if(ans=='y') {
-
printf("\nEnter record number :");
-
gets(rec);
-
fseek(fp,((atoi(rec)-1)*sizeof(payroll_rec)),SEEK_SET);
-
strcpy(payroll_rec.no,"\0");
-
strcpy(payroll_rec.name,"\0");
-
payroll_rec.salary=NULL;
-
payroll_rec.rate=NULL;
-
payroll_rec.net=NULL;
-
fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
-
if(ferror(fp)) {
-
printf("Error for delete data\n");
-
getch();
-
exit(1);
-
}
-
printf("Delete data complete\n");
-
}
-
printf("\nContinue(press c) or Exit(press e) :");
-
ans=getche();
-
printf("\n");
-
}while(ans!='e');
-
fclose(fp);
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Newbee Adam |
last post by:
I have been reading in help how I need to use decimal becuase currency does
not exist like I used in vb6.
I had a difficult time on google and msdn finding how or if I can take the
value of text box as decimal or do I just have to make another decimal
variable
.. So I took a guess hoping CDec would come up blue if I type it in with no
squigglies on the line. But is this actually converting it to decimal.
Next if so, I do not like the...
|
by: Megat |
last post by:
I'm trying to create a conversion program, that convert a simple
proprietry programming language to an international standard
languange, using Visual C++. Need some help from those who has
experience or anyone who has any idea in creating such program.
Really appreciate your help.
Thank you
|
by: prabha |
last post by:
Hello Everybody,
I have to conert the word doc to multiple html files,according to the templates in the word doc.
I had converted the word to xml.Also through Exsl ,had finished the multiple output html files.
The problem is while reading through the worddoc paragraph,the special characters are not identified.
So in the xml file,it's just storing that as "?".So I couldn't able to retrive the characters in my ouput html files.
|
by: Jake Jessup |
last post by:
A client wants me to do a conversion from Access 2.0 (yeah, I know, unreal).
The problem is, she doesn't have the install disks and I haven't had a copy
of 2.0 in years.
If some kind should could kindly point me to a place where I might get a
copy, I would be grateful.
I'm willing to do a trade for it.
|
by: Robert |
last post by:
I have a series of web applications (configured as separate applications) on
a server.
There is a main application at the root and then several virtual directories
that are independant applications.
I am testing an upgrade of all of the sites and have converted the main root
site...although not necessarily fixed any issues.
I move on instead and converted one of the virtual roots that is a seperate
| |
by: sam_cit |
last post by:
Hi,
I needed help in converting a character to the correspoding
hexadecimal values, like the following example,
ASCII value : ABC
Hex Code Value : %41%42%43...
whats the logic of conversion...
|
by: manmit.walia |
last post by:
Hello All,
I have tried multiple online tools to convert an VB6 (bas) file to
VB.NET file and no luck. I was hoping that someone could help me covert
this. I am new to the .NET world and still learning all help would be
greatly apperciated.
Attribute VB_Name = "Module1"
Option Explicit
|
by: Mhel |
last post by:
Hi everyone! I need some help in Converting Infix to postfix.I need a program that would do it.
Please, I really need help.
|
by: Hank Stalica |
last post by:
I'm having this weird problem where my code does the following
conversion from string to float:
27000000.0 -27000000.00
2973999.99 -29740000.00
2989999.13 -2989999.25
The number on the left is the string I get after tokenizing a bigger
string. The number on the right is the number I get after the conversion.
|
by: helpwithcode |
last post by:
Hi people,
I am just learning java.I have been creating a project which involves JDBC Connectivity.I find that the statements,
String string_dob=text_dob.getText();
//Converting string to date
System.out.println(string_dob);
s.Info_DOB=Date.valueOf(string_dob);
runs perfectly fine in the method insert() and throws up an illegal Exception in the method UPDATE.This is the error I get when I pass a date "1979-05-02"
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |