joep@Stardent.COM (Joe Peterson) (05/03/91)
Since people seem interested in programs to calculate logbook info, I thought I would post the program I use. It is fairly simple. It looks for a file called "logbook.dat", while is a series of lines such as: 9000 45 3500 10 8000 39 0 0 This would be three jumps (the last 0 0 is an end marker). The first number on each line is the altitude, and the second is the freefall time in seconds. The program calculates total jumps, freefall jumps (more than 0 seconds), and total freefall time. It also prints a chart similar to the one you need for your license application (I think this might be a time saver!). Enjoy! Joe Peterson C-20351 /* Logbook program - Joe Peterson */ #include <stdio.h> #define MAX_JUMPS 1000 int jump_chart[(MAX_JUMPS-1)/10+1][5], total[5]; main() { FILE *in; int jumps, freefalls, hours, mins, secs; int altitude[MAX_JUMPS], time[MAX_JUMPS]; int i, group, num_groups; in= fopen("logbook.dat", "r"); jumps= 0; hours= mins= secs= 0; while (1) { fscanf(in, "%d %d", &altitude[jumps], &time[jumps]); if (altitude[jumps] == 0) break; ++jumps; } fclose(in); for (group=0; group<(MAX_JUMPS/10); ++group) for (i=0; i<5; ++i) jump_chart[group][i]= 0; for (i=0; i<5; ++i) total[i]= 0; freefalls= 0; for (i=0; i<jumps; ++i) { group= i / 10; if (time[i] == 0) { ++jump_chart[group][0]; ++total[0]; } else if (time[i] <= 39) { ++jump_chart[group][1]; ++total[1]; ++freefalls; } else if (time[i] <= 44) { ++jump_chart[group][2]; ++total[2]; ++freefalls; } else if (time[i] <= 59) { ++jump_chart[group][3]; ++total[3]; ++freefalls; } else { ++jump_chart[group][4]; ++total[4]; ++freefalls; } secs += time[i]; while (secs >= 60) { ++mins; if (mins == 60) { ++hours; mins= 0; } secs -= 60; } } num_groups= (jumps - 1) / 10 + 1; printf(" "); for (group=0; group<num_groups; ++group) printf("%2d ", group + 1); printf(" Total\n"); printf(" -"); for (group=0; group<num_groups; ++group) printf("---"); printf("------\n"); printf("Static lines: "); for (group=0; group<num_groups; ++group) printf("%2d ", jump_chart[group][0]); printf(" %4d\n", total[0]); printf("1 to 39 secs: "); for (group=0; group<num_groups; ++group) printf("%2d ", jump_chart[group][1]); printf(" %4d\n", total[1]); printf("40 to 44 secs: "); for (group=0; group<num_groups; ++group) printf("%2d ", jump_chart[group][2]); printf(" %4d\n", total[2]); printf("45 to 59 secs: "); for (group=0; group<num_groups; ++group) printf("%2d ", jump_chart[group][3]); printf(" %4d\n", total[3]); printf("60 or more secs: "); for (group=0; group<num_groups; ++group) printf("%2d ", jump_chart[group][4]); printf(" %4d\n\n", total[4]); printf("Total jumps: %d\n", jumps); printf("Total freefalls: %d\n", freefalls); printf("Total freefall time: %d:%02d:%02d\n", hours, mins, secs); }