I'm trying to write program using classes to create a grade book.
This is what I have so far:
Code:
#include <stdio.h>
void addGrade(float grades[],int counter);
void removeGrade(float grades[],int counter);
void sortGrade(float grades[],int counter);
void printGrade(float grades[],int counter);
void findMinMax(float grades[],int counter);
void calcAverage(float grades[],int counter);
main()
{
float grades[15]={87,69,98,48};
int counter=4;
int option;
//Main Menu
do
{printf("Select one of the options:\t");
scanf("%d",&option);
fflush(stdin);
switch(option)
{
case 1: //add Grades
printf("Add Grades\n");
addGrade(grades,counter);
break;
case 2://Remove Grades
printf("Remove Grades\n");
removeGrade(grades,counter);
break;
case 3://Sort Grades
printf("Sort Grades\n");
sortGrade(grades,counter);
break;
case 4://Print Grades
printf("Print Grades\n");
printGrade(grades,counter);
break;
case 5://Find Max Min
printf("Find Max/Min Grades\n");
findMinMax(grades,counter);
break;
case 6://Calculate Average
printf("Calculate Average\n");
calcAverage(grades,counter);
break;
case 7:
printf("Bye Bye Mr. American Pie!\n");
break;
}while(option!=7);
void addGrade(float grades[],int counter);
{
//Calculate the number of free locations
int number=15-counter;
//get number of grades from user
int numbgrade;
//get grades
int i;
for(i=0;i<numbgrade;i++)
scanf("%f",&grades[counter+numbgrade+i]);
counter=counter+numbgrade;
}
void removeGrade(float grades[], int counter);
{
int number;//get index number of grades
scanf("%d",&number);
printf("Are you sure to remove %f\n",grades[number]);
printf("yes or no\n");
int i;
for(i=number;i<14;i++)
grades[i]=grades[i+1];
//validation of that number
//remove grade
}
void sortGrade(float grades[],int counter);
{
//bubble sort grades
}
void printGrade(float grades[],int counter);
{
int x;
for(x=0;x<15;x++);
printf("%f %d",grades, counter);
}
void findMinMax(float grades[],int counter);
{
//find min max in slides
}
void calcAverage(float grades[],int counter);
{
//calculate average
}
The ones with comment sections ares the ones I will be filling the codes in. I'm trying to figure out how to write my remove function. Thank you in Advance. Note: If it is vague I will try to post the actual question from my assignment.