Good Morning,

I'm having some problems with my code. This program is to have at least 5 functions .

1.)Ingrades: a two dimensional array that stores student ID, grades and times absent.

2.)Score. Calculates scores for all course work (two partial tests 15% each , two quizzes 10 %each, 1 project 20%1 final 30%.

3.standev - calculates the standard deviation of each course work

4.Modif - lets user modify any score or absent total

5.ViewGradesl: outputs all the grades for each student ID entered

My problem so far, my code runs, but I'm having major problems with the following functions:

1.)Ingrade: my problem here is that I'm not really sure in which index I'm storing the Absence Count.

2.) Score : I made it really simple assuming all scores where the same. But I'm having problems trying to give a 15% value to tests and 10% ten to quizzes and so on.. so in the end I can compute the final grade correctly. And also I have problems when running the subtraction of -1% if student is absent it is deducted a 1% of the final grade. and if the student is absent more than than ten times it is an F. I can put all 100 and 1 absent and the program sometimes gives out an F.

3.)standev: This works ok (I think )

4.) Modif: welll , where to start with this one?. It is supposed to modify the original array with new grades for each student ID and then recompute using function score. but any sort of value I enter I don't know where I'm sending it. I thought I was sending it to the original array but apparently I'm not

5.) ViewGrades works ok, displaying each student id and all grades , but I wish to modify it to actually display some sort of table.

I would gladly appreciate any ideas or help I'm exhausted with this project

```
#include<iostream> //Librerias
#include<cmath> //Librerias
using namespace std;
/* Function prototypes */
void Ingrades (double[][10], int); // Function that lets user input student ID, two partial exams one final, two quizzes and one project and studentCount of twenty classes
void Score (double[][10], int);//Score and mean calculations
void Standev (double[][10], int); //Function that calculates standard deviation
void Modif (double [][10], int); //Function that lets user change any student grades for any test and studentCount
void ViewGrades (double[][10], int); //Function that displays the Score of each test for each student and outputs the final grade.
int main ()
{
const int studentCount=15, studentRecords=10;//We initialize arrays to dimensions studentCount is twenty max number of classes and studentRecords fifteen max number of students.
int option, i, studentID;
/* MultiDemensional Array : first dimension is fifteen that represents the student count
Second dimension is ten that represents the student records to be modified
zero row represents students ID
rows one to seven represents student grades composed of : two partial tests, two quizzes, one project and one final
row eight represent ABSENCES
row nine represents final grade
*/
double gradeBook[studentCount][studentRecords];
cout<<" \t \t Student GradeBook "<<endl;
cout<<"Enter the amount of the students (1 to 15): ";
cin>>studentID; // asks for total number of students
while(studentID<1 ||studentID>15)//student count is 15
{
cout<<"The student quantity should be from 1 to 15. \nPlease Re-Enter: ";
cin>>studentID;
}
for (i=0; i<studentID; i++)//Array initialized to 0
{
gradeBook[i][0]=0;
gradeBook[i][10]=-1;
}
do // do loop for menu
{
option=0;
/* Options Menu*/
cout<<"1. Enter the student grades (2 partial exams, 2 quizzes, 1 proyect 1 final ) and studentRecords (20 total attendance)"<<endl;
cout<<"2. Compute each student's mean score and final grade"<<endl;
cout<<"3. Compute the variance and the standard deviation for each exam and final score";
cout<<"4. Modify Grades"<<endl;
cout<<"5. List the Grades"<<endl;
cout<<"6. Exit"<<endl;
cout<<"Please choose an option: ";
cin>>option;
cout<<endl<<endl;
while(option<1||option>6)// validation loop
{
cout<<"ERROR INVALID SELECTION"<<endl;
cout<<"Please, re-enter one of the earlier options: ";
cin>>option;
}
switch (option)// Selection menu to populate the arrays
{
case 1:
if(gradeBook[0][0]!=0)// validation statement
{
cout<<"This process can't be done again."<<endl;
cout<<"Select options 2-6."<<endl<<endl;
}
else
Ingrades(gradeBook, studentID);//call for Ingrades function with gradebook and studentID
break;
case 2:
Score(gradeBook, studentID);//calls for function Score that calculates scores for gradebook and student id dimensions
break;
case 3:
Standev(gradeBook, studentID);// calls for function Standdev for a all tests
break;
case 4:
Modif(gradeBook, studentID);//calls for function Modif that lets user modify any student record including test and Attendance
break;
case 5:
ViewGrades(gradeBook, studentID);//View Grades for entire class or students entered
break;
case 6:
cout<<"GOOD BYE "<<endl<<endl;
break;
}
// All functions called and they send parameters to each function definition.
}while(option>=1&&option<=5);
return 0;
}
//end main
/* Function DEFINITIONS */
void Ingrades (double gradeBook[][10],int studentCount)//
{
// i represents students count and j represents student data: grades, ID and absent count
int i, j;
for(i=0; i<studentCount; i++)//studentCout initialized to 0
{
for(j=0; j<1; j++)// For repetition cycle that asks for students ID
{
cout<<"Enter the student's ID number: ";
cin>>gradeBook[i][j];
while(gradeBook[i][j]<=0)//Student id cannot be <= 0
{
cout<<"Invalid ID Number. Re-enter again....: ";
cin>>gradeBook[i][j];
}
}
cout<<"Enter in the following order: \n test1 = 1, test2= 2, quiz1= 3, quiz2= 4, project1= 5 FINAL =6"<<endl;
for(j=1; j<7; j++)//
{
cout<<"Enter the grades "<<j<<": ";
cin>>gradeBook[i][j];
while(gradeBook[i][j]>100||gradeBook[i][j]<0)// gradeBook validated that grades cannot be lower than zero and greater than a hundred
{
cout<<"INVALID GRADES"<<endl;
cout<<"Please Re-Enter: ";
cin>>gradeBook[i][j];
}
}
for(j=8; j<9; j++)//Counts for Absences
{
cout<<"Enter the student's number of absences (Total of clases: 20): ";
cin>>gradeBook[i][j];
while(gradeBook[i][j]<0||gradeBook[i][j]>20)// while validation Class total is twenty , Absences cannot be more than the total of classes
{
cout<<"**The number of absences exceed the number of classes**"<<endl;
cout<<"Re-enter: ";
cin>>gradeBook[i][j];
}
cout<<endl<<endl;
}
}
}
void Score (double gradeBook[][10],int studentCount)//Function that calculates students grade
{
int i, j;
for (i=0; i<studentCount; i++) // To call for this function you have to select option 1 in main that populates student Records
if (gradeBook[i][0]==0)
{
cout<<"***No students were registered***.";
cout<<"Select Option 1."<<endl;
break;
}
else // IF there's a valid ID entered then function is executed
{
for (i=0; i<studentCount; i++)
{
if(gradeBook[i][8]>=10) //row eight is where ABSENCES are stored
gradeBook[i][10]=0;//If there are more than ten ABSENCES then GRADE is F
else
{
for(i=0; i<studentCount; i++)
{
for (j=0; j<gradeBook[i][8]; j++)
gradeBook[i][10]-=1.0;//Rests 1.0% out of the final grade for each ABSENCE
if(gradeBook[i][10]<0)
gradeBook[i][10]=0;//IF Final grade is negative then score is F.
}
}
}
}
cout<<"*************************************"<<endl;
cout<<"* All the calculations have been done *"<<endl;//
cout<<"*************************************"<<endl<<endl<<endl<<endl;
}
void Standev (double gradeBook[][10], int studentCount)//Function that calculates Standard Deviation
{
int i, j, a, w;
double sum, average, rum, stdVariance, std_deviation;
for(a=0; a<studentCount; a++)
{ // Validation for initial values of the array, GRADES must be entered for this function to work
if (gradeBook[0][0]==0)
{
cout<<"No Grades were registered."<<endl;
cout<<"Select Option 1."<<endl;
break;
}
else if(gradeBook[0][10]==-1)
{
cout<<"No calculations have been made nor grades were registrered."<<endl;
cout<<"Select Option 2."<<endl<<endl<<endl;
break;
}
else
{
do// Repeats Standard Deviation MENU
{
cout<<"Press 1 to see the variance and standard deviation of the first exam."<<endl;
cout<<"Press 2 to see the variance and standard deviation of the second exam."<<endl;
cout<<"Press 3 to see the variance and standard deviation of the first quiz"<<endl;
cout<<"Press 4 to see the variance and standard deviation of the second quiz"<<endl;
cout<<"Press 5 to see the variance and standard deviation of the project 1"<<endl;
cout<<"Press 6 to see the variance and standard deviation of the final exam."<<endl;
cout<<"Press 7 to see the variance and standard deviation of the final score."<<endl;
cout<<"Press 8 to exit."<<endl;
sum=0;
rum=0;
average;
stdVariance=0;
std_deviation=0;
w=0; // Second menu Selection
cin>>w;
while(w<1||w>8)//Validates MENU
{
cout<<"***Error***===Please Re-Enter.";
cin>>w;
}
switch (w)
{ // Each CASE Computes the standard deviation of all grades for each EXAM
case 1:
for(i=0; i<studentCount; i++)
for(j=1; j<2; j++)
sum+=gradeBook[i][j];//Sums all of the GRADES of Examn ONE.
average=sum/studentCount;//Divide the sum of the GRADES entered by the total of students entered (Average)
for(i=0; i<studentCount; i++)
for(j=1; j<2; j++)
rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);//Stores the sum in a variable
stdVariance=rum/(studentCount-1);//divides the calculation by the total number of grades minus one to get curve
std_deviation=sqrt(stdVariance); // sqrt of variation, using sqrt from cmath library gives out the Std deviation
cout<<"Variance for the first test is: "<<stdVariance<<endl;
cout<<"Standard deviation for the first test is is: "<<std_deviation<<endl<<endl;
break;
case 2: //Calculates standard deviation for the second test
for(i=0; i<studentCount; i++)
for(j=2; j<3; j++)
sum+=gradeBook[i][j];
average=sum/studentCount;
for(i=0; i<studentCount; i++)
for(j=2; j<3; j++)
rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
stdVariance=rum/(studentCount-1);
std_deviation=sqrt(stdVariance);
cout<<"Variance for the second test is: "<<stdVariance<<endl;
cout<<"Standard deviation for the second test is is: "<<std_deviation<<endl<<endl;
break;
case 3: //Calculates standard deviation for quiz one
for(i=0; i<studentCount; i++)
for(j=3; j<4; j++)
sum+=gradeBook[i][j];
average=sum/studentCount;
for(i=0; i<studentCount; i++)
for(j=3; j<4; j++)
rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
stdVariance=rum/(studentCount-1);
std_deviation=sqrt(stdVariance);
cout<<"Variance for the first quiz is: "<<stdVariance<<endl;
cout<<"Standard deviation for the first quiz is: "<<std_deviation<<endl<<endl;
break;
case 4://Calculates standard deviation for quiz two
for(i=0; i<studentCount; i++)
for(j=4; j<5; j++)
sum+=gradeBook[i][j];
average=sum/studentCount;
for(i=0; i<studentCount; i++)
for(j=4; j<5; j++)
rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
stdVariance=rum/(studentCount-1);
std_deviation=sqrt(stdVariance);
cout<<"Variance for the second quiz is: "<<stdVariance<<endl;
cout<<"Standard deviation for the second quiz is: "<<std_deviation<<endl<<endl;
break;
case 5://Calculates standard deviation for project
for(i=0; i<studentCount; i++)
for(j=5; j<6; j++)
sum+=gradeBook[i][j];
average=sum/studentCount;
for(i=0; i<studentCount; i++)
for(j=5; j<6; j++)
rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
stdVariance=rum/(studentCount-1);
std_deviation=sqrt(stdVariance);
cout<<"Variance for the project is: "<<stdVariance<<endl;
cout<<"Standard deviation for the project is : "<<std_deviation<<endl<<endl;
break;
case 6: //calculates standard deviation for FINAL TEST
for (i=0; i<studentCount; i++)
for (j=7; j<8; j++)
sum+=gradeBook[i][j];
average=sum/studentCount;
for(i=0; i<studentCount; i++)
for(j=7; j<8; i++)
rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);
stdVariance=rum/(studentCount - 1);
std_deviation=sqrt (stdVariance);
cout<<"Variance for the final exam is: "<<stdVariance<<endl;
cout<<"Standard deviation for the final exam is: "<<std_deviation<<endl<<endl;
break;
case 7: // calculates the standard deviation of the FINAL GRADE
for(i=0; i<studentCount; i++)
for(j=8; j<9; j++)
sum+=gradeBook[i][j];//Sums all of the GRADES of Final Grade.
average=sum/studentCount;//Divide the sum of the GRADES entered by the total of students entered (Average)
for(i=0; i<studentCount; i++)
for(j=8; j<9; j++)
rum+=(gradeBook[i][j]-average)*(gradeBook[i][j]-average);//Stores the sum in a variable
stdVariance=rum/(studentCount-1);//divides the calculation by the total number of grades minus one to get curve
std_deviation=sqrt(stdVariance); // sqrt of variation, using sqrt from cmath library gives out the Std deviation
cout<<"Variance for the FINAL GRADE is: "<<stdVariance<<endl;
cout<<"Standard deviation for the FINAL GRADE is: "<<std_deviation<<endl<<endl;
break;
case 8:// Menu Exits
break;
}
}while(w>=1&&w<=8);
}
if(w==8)// if hits 8 goes back to previous menu
break;
}
}
void Modif (double gradeBook[][10], int studentCount)//Function that permits the change student grades and Attendance
{
int i, k, ghj;
if (gradeBook[0][0]==0)//array initialized
{
cout<<"No student were registered"<<endl;
cout<<"Please, refer to option 1."<<endl;
}
else
{
for(i=0; i<studentCount; i++)
{
cout<<"You can Modif the student's grades in the order you entered them, or skip to the other student.\n";
cout<<"Student # " <<i+1<<" ( ID# "<<gradeBook[i][0]<<" )" <<endl<<endl;
do
{
cout<<"Enter 1 to Modify the grade of the first test."<<endl;
cout<<"Enter 2 to Modify the grade of the second test."<<endl;
cout<<"Enter 3 to Modify the grade of the first quiz"<<endl;
cout<<"Enter 4 to Modify the grade of the second quiz."<<endl;
cout<<"Enter 5 to Modify the grade of the project"<<endl;
cout<<"Enter 6 to Modify the grade of the FINAL TEST"<<endl;
cout<<"Enter 7 to Modify the absences."<<endl;
cout<<"Enter 8 to skip this student, or to exit."<<endl<<endl;
k=0;
ghj=0;
cin>>k;
while(k<1||k>8)
{
cout<<"***Invalid Option***\n Please Re-Enter: ";
cin>>k;
}
switch (k)
{
case 1: //each case validates for wrong values and modifies existing values in gradeBook
cout<<"Enter the new score for first test: ";
cin>>ghj;
while(ghj>100||ghj<0)
{
cout<<"***Invalid Grade Value*** Re-Enter: ";
cin>>ghj;
}
gradeBook[i][1]=ghj;
cout<<"New value for grade of the first test is: "<<gradeBook[i][1]<<"%"<<endl<<endl;
break;
case 2:
cout<<"Enter the new score for second test: ";
cin>>ghj;
while(ghj>100||ghj<0)
{
cout<<"***Invalid Grade Value***\n Please Re-Enter: ";
cin>>ghj;
}
gradeBook[i][2]=ghj;
cout<<"New value for grade of the second test is: "<<gradeBook[i][2]<<"%"<<endl<<endl;
break;
case 3:
cout<<"Enter the new score for the first quiz: ";
cin>>ghj;
while(ghj>100||ghj<0)
{
cout<<"***Invalid grade value***\nPlease Re-Enter: ";
cin>>ghj;
}
gradeBook[i][3]=ghj;
cout<<"New value for grade of the first quiz is: "<<gradeBook[i][3]<<"%"<<endl<<endl;
break;
case 4:
cout<<"Enter the new score for the second quiz: ";
cin>>ghj;
while(ghj>100||ghj<0)
{
cout<<"***Invalid Grade Value***\nPlease Re-Enter: ";
cin>>ghj;
}
gradeBook[i][4]=ghj;
cout<<"New value for grade of the second quiz is: "<<gradeBook[i][4]<<"%"<<endl<<endl;
break;
case 5:
cout<<"Enter the new score for the project: ";
cin>>ghj;
while(ghj>100||ghj<0)
{
cout<<"***Invalid Grade Value***\nPlease Re-Enter: ";
cin>>ghj;
}
gradeBook[i][5]=ghj;
cout<<"New value for grade of the project is: "<<gradeBook[i][4]<<"%"<<endl<<endl;
break;
case 6:
cout<<"Enter the new score for the FINAL TEST ";
cin>>ghj;
while(ghj>100||ghj<0)
{
cout<<"***Invalid Grade Value***\nPlease Re-Enter: ";
cin>>ghj;
}
gradeBook[i][6]=ghj;
cout<<"New value for grade of the FINAL TEST is: "<<gradeBook[i][4]<<"%"<<endl<<endl;
break;
case 7:
cout<<"Enter the new number of absences: ";
cin>>ghj;
while(ghj>20||ghj<0)//Validation of attendance only twenty classes
{
cout<<"Remember, there are only 20 classes and the value cannot be negative...."<<endl;
cout<<"Please re-enter: ";
cin>>ghj;
}
gradeBook[i][7]=ghj;
cout<<"New value for absences is: "<<gradeBook[i][7]<<endl<<endl;
break;
}
if(k==8)
{
break;
}
}while(k>=1&&k<=7);
}
cout<<"Choose option 2 to calculate the new grades or absences..."<<endl<<endl;
//Then user needs to perform option two in main menu to calculate the new grades based on new data entered
}
}
void ViewGrades (double gradeBook[][10], int studentCount)//This function show the wholes grade for each student
{
int i, j, k;
double note=0;
char x;
if (gradeBook[0][0]==0)
cout<<"No ID numbers were entered. Select to option 1."<<endl<<endl;
else if(gradeBook[0][10]==-1)
cout<<"No calculations have been made. Select option 2."<<endl<<endl;
else
{
for(i=0; i<studentCount; i++)//Student count
{
for(j=0; j<1; j++)//First row is for ID
{
cout<<"The scores for student's (With ID #: "<<gradeBook[i][j]<<")tests are:\n";
for(k=1; k<7; k++)//GRADES are positions from 1, 2, 3, 4,5, 6,7 of array
cout<<gradeBook[i][k]<<"%"<<endl;
cout<<"With ";
for(k=8; k<9; k++)//Remember position 8 of the array is for the ATTENDANCE
cout<<gradeBook[i][k];
cout<<" absences to class."<<endl;
cout<<"Final grade is ";
if (gradeBook[i][10]<=100&&gradeBook[i][10]>=90)
x='A';// if final avarage is between 90 & 100 it's an A
else if (gradeBook[i][10]<=89&&gradeBook[i][10]>=80)
x='B';// if final avarage is between 80 & 89 it's a B
else if (gradeBook[i][10]<=79&&gradeBook[i][10]>=70)
x='C';// if final avarage is between 70 & 79 it's a C
else if (gradeBook[i][10]<=69&&gradeBook[i][10]>=60)
x='D';// if final avarage is between 60 & 69 it's a B
else
x='F';// If its lower than 59 then it's an F
cout<<x<<"(";
for(k=7; k<8; k++)
cout<<gradeBook[i][10];
cout<<"%)."<<endl<<endl; //prints out final grade letter and percent
}
}
}
}
```