Hello all I am needing to get this program to print off a report listing the data entered and then at the end put each employees total pay and then the overall total pay of everyone. It doesn't have to export a file, simply print the result. This is the code I have so far and it is simply producing a jumbled output, help would be great
Code:
#include <stdio.h>#define NUMRECS 6
struct payrecord
{
int id;
char name[20];
float rate;
float hrs;
};
int main()
{
int i;
struct payrecord employee[NUMRECS] = {{3462, "Jones", 6.62, 40.0},
{6793, "Robbins", 5.83, 38.5},
{6985, "Smith", 5.22, 45.5},
{7834, "Smith", 6.89, 40.0},
{8867, "Timmins", 6.43, 35.5},
{9002, "Williams", 4.75, 42.0},
};
float total[NUMRECS];
float otot=0;
for (i=0; i<NUMRECS; i++)
total[i]=employee[i].rate*employee[i].hrs;
otot=otot+total[i];
printf ("%d %-20s %4.2f %2.1f %1.1f %f\n",
employee[i].id, employee[i].name, employee[i].rate, employee[i].hrs, total[i], otot);
system ("PAUSE");
return 0;
}