#include <stdio.h>
/* Terry Harvey  CISC 105 Section: 00  TA: Sprenkle */

/*
 * This program computes your semester grade based on the percentages
 * from the syllabus. Assume there will be no curve; typically my 105
 * classes have little or no curve, and grade divisions come at 90,
 * 80, etc.  
 *    I bet you can write a nicer version of this program that
 * would read your grades from a file and count them as it reads. If
 * you write a nice one, send it to me and I'll have other classes use it.
 */

//DO NOT ALTER THE PERCENTAGES
#define PERCENT_MIDTERMS 0.30
#define PERCENT_FINAL 0.25
#define PERCENT_LABS 0.12 //.03 of this is lab attendance, per the syllabus
#define PERCENT_QUIZZES 0.08
#define PERCENT_PROJECTS 0.20
#define PERCENT_PARTICIPATION 0.05

//ALTER THESE NUMBERS TO REFLECT NUMBER OF GRADES YOU HAVE NOW
#define NUM_PROJECTS 2
#define NUM_MIDTERMS 2
#define NUM_LABS 2
#define NUM_QUIZZES 2

double calculateContribution(double grades[], int size, double factor);

int main(){

    ///PUT YOUR GRADES HERE, THEN CHANGE SIZE ABOVE
    double labs[] = {100,100};//{51.4, 67.3, 98};
    double quizzes[] = {100,100};//{51.4, 67.3};
    double midterms[] = {100,100};//{81.4, 67.3};
    double projects[] = {100,100};//{51.4, 67.3};
    double final = 100;
    double participation = 100;

    double total = 0;
    total += calculateContribution(labs, NUM_LABS, PERCENT_LABS);
    total += calculateContribution(quizzes, NUM_QUIZZES, PERCENT_QUIZZES);
    total += calculateContribution(projects, NUM_PROJECTS, PERCENT_PROJECTS);
    total += calculateContribution(midterms, NUM_MIDTERMS, PERCENT_MIDTERMS);
    total += final * PERCENT_FINAL;
    total += participation * PERCENT_PARTICIPATION;


    printf("%2.1lf\n", total);

    return 0;
}

/*
 * Calculates the contribution of a single kind of assignment. Pass
 * parameters: array of grades, num grades = size, factor is the
 * percentage that this type of assignment counts in the final grade.
 */
double calculateContribution(double grades[], int size, double factor){
    int i;
    double sum = 0;
    for (i = 0; i < size; i++){
        sum += grades[i];
    }

    return sum / size * factor;
}
