Hi there guys and good morning!
I'm quite new to programming and forgive me if I'm quite slow with it. Takes me ages to code alone and this is the only part (finally) I have left to do. The teacher gave us an algorithm for the program so we would have to change that into a workable code for our final program.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef short BOOLEAN;
typedef char STR15[15 + 1];
typedef char STR10[10 + 1];
typedef struct PayRecord
{
STR15 LastName;
STR10 FirstName;
float hours, payrate, deferred, gross, fedtax, statetax, ssitax, net;
float reghrs, ovthrs;
float totreg, totovt, totrate, totgross, totfed, totstate, totssi, totdefr, totnet;
} PayRecord;
#define BLANK "* *\n"
#define BORDER "************************************************************\n"
#define HEADER "* Check No %3d *\n"
#define HEADER2 "* Sabre Corporation *\n"
#define HEADER3 "* 15790 West Henness lane *\n"
#define HEADER4 "* New Corio, New Mexico 65790 *\n"
#define HEADER5 "* Pay to the Order of *\n"
#define HEADER6 "* %-16s *\n"
#define HEADER7 "* %-54s *\n"
#define HEADER8 "* Reference: %-16s *\n"
void convertNetPay(float net, char *netPayString)
{
int numHuns, numTens, numOnes;
char OnesTable[9][8] = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
char TensTable[9][8] = { "Ten", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
char TeensTable[9][11] = { "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" };
float cents;
cents = net - int(net);
strcpy(netPayString, "The Sum of ");
numHuns = int(net) / 100;
if (numHuns > 0)
{
strcat(netPayString, OnesTable[numHuns - 1]);
strcat(netPayString, " Hundred ");
}
int remainder = int(net) % 100;
if ((remainder >= 11) || (remainder <= 19))
{
strcat(netPayString, TeensTable[remainder - 11]);
}
else
{
numTens = int(net) % 100 / 10;
numOnes = int(net) % 100 % 10;
if (numTens > 0)
{
strcat(netPayString, TensTable[numTens - 1]);
strcat(netPayString, "-");
}
if (numOnes > 0)
{
strcat(netPayString, OnesTable[numOnes - 1]);
}
}
strcat(netPayString, " Dollars and ");
cents = cents + 0.005;
cents = cents * 100;
cents = int(cents);
char ResultString[10 + 1];
sprintf(ResultString, "%s", int(cents));
strcat(netPayString, ResultString);
}
void printCheckHeader(PayRecord EmployeeData[], char *CheckName, char *netPayString, int chkNo, char *refCode, int count)
{
printf(BORDER);
printf(HEADER, chkNo);
printf(BLANK);
printf(HEADER2);
printf(HEADER3);
printf(HEADER4);
printf(BLANK);
printf(BLANK);
printf(HEADER5);
printf(BLANK);
printf(HEADER6, CheckName);
printf(BLANK);
printf(HEADER7, netPayString);
printf(BLANK);
printf(BLANK);
printf(HEADER8, refCode);
printf(BLANK);
printf(BLANK);
printf(BORDER);
}
int main(void)
{
PayRecord EmployeeData[MAXEMPLOYEES];
char FullName[15 + 10 + 1];
char CheckName[15 + 10 + 1];
char *netPayString;
char *refCode;
int count;
int chkNo = 100;
FILE *reportFile;
reportFile = fopen("./report.txt", "wt");
if (reportFile == NULL)
{
printf(" report file open failed ...\n");
fflush(stdin);
exit(-30);
}
for (count = 0; count < MAXEMPLOYEES; count++)
{
refCode = generateRefCode(EmployeeData, chkNo, count);
strcpy(CheckName, EmployeeData[count].FirstName);
strcat(CheckName, " ");
strcat(CheckName, EmployeeData[count].LastName);
printCheckHeader(EmployeeData, CheckName, netPayString, chkNo, refCode, count);
printCheckStub(EmployeeData, CheckName, chkNo, count);
chkNo++;
}
This occurs at printCheckHeader() in int main(). Help please!