#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define SIZE 9
//* header functions *//
void testvalue(int numtests, double percentages[]);
void grade(int numtests, double percentages[], double score[], double weightedaverage[]);
//* functions *//
//* function that catalogs the value of each test *//
void testvalue(int numtests, double percentages[])
{
int count;
double sum = 0;
for(count = 0; count < numtests; count++){
printf("Enter the percentage value of each test\n");
scanf("%f", &percentages[count]);
printf("This test is worth %4.2f points.\n", percentages[count]);
sum += percentages[count];
if (sum > 100){
printf("percentages were entered in error, please try again\n");
sum = 0;
}
}
return;
}
//* the function that determines the grade value *//
void grade(int numtests, double percentages[], double score[], double weightedavge[])
{
int count;
for(count = 0; count < numtests; count++){
printf("enter the grades you've gotten for each test\n");
scanf("%d", &score[count]);
printf("%d\n", grade[count]);
weightedavge[count] = (grade[count] * percentages[count]);
}
return;
}
int main()
{
int numtests, count, choice;
double percentages[SIZE], score[SIZE], weightedavge[SIZE];
printf("This program will help answer all your questions about your grade");
printf("Please enter the number of tests that will be given throughout the semester");
//* acquiring the number of *//
//* tests taken from the user *//
scanf("%d", &numtests);
//* as well as gauge the size of the arrays *//
if (numtests > 0)
printf("There are %d tests this semester\n", numtests);
else {
printf("Invalid number of marks\n");
exit(1);
}
//* runs the value function to determine *//
//* the percentage value of each test *//
testvalue(numtests, percentages[SIZE]);
printf("If you've never missed a test, type 1, otherwise, type 2");
//*check to see if the user has ever missed a test*//
scanf("%d", &choice);
if (choice == 1){
grade(numtests, percentages[SIZE], score[SIZE], weightedavge[SIZE]);
for(count = 0; count < numtests; count++) {
printf("%f", weightedavge[count]);
}
}
return 0;
}