Intro Resources Bib Address NQ
 

Gradebook 1.0

 

Here is the C source code for my gradebook program. It prompts you to enter the value of assignments so far (e.g., 100 for 100% of all assignments, or 53%, for example, if you are calculating midterm grades). I find it saves me a great deal of time.


/*
* Gradebook 1.0 Beta
*
* ©Steve Harris 1998-99, Chicago, IL
*/

/******************************** MAIN */
#include <stdio.h>
#include <stdlib.h>

float fin, p, va[25], a[25], wor;
int i, asg;

int main(void)
{
    printf(" Welcome to Adjunct Grader.\n\n ©Steve Harris 1998-99\n\n");

    printf("How many assignments so far? ");
    scanf("%d",&asg);

    printf("\nWhat percentage of 100 are they worth? ");
    scanf("%f",&wor);
    printf("\n");

    for (i=1; i<=asg; i++)
        { printf("Value of Assignment %d? ", i);
        scanf("%f",&va[i]);
        if ( va[i] == 1)
            va[i] = va[i] * 0.10000;
        else
            va[i] = va[i] * 0.01000;
        }

        do
        { p=0.00000;
            printf("\n");

            for(i=1; i<=asg; i++)
            { printf("Student's grade on assignment %d? ", i);
                scanf("%f",&a[i]);
            p = (va[i] * a[i]) + p;
            }

            fin = (p/wor);
            printf("\n Final grade for student is %1.5f", fin);
            printf("\n_____________________\nAnother student (y/n)?");
            if (getchar() == 'n')
            { printf("\n\nThank you for using Adjunct Grader. Goodbye.");
            break;
            }
        }
    while ( getchar() != 'n');
    printf("\n\nThank you for using Adjunct Grader. Goodbye.");

    return 0;
}