4. Calculate each student letter grade using a function, save the letter grade to another array defined in main function.
5. Return the count of the grades for each letter grade (A, B, C,D, F) using a function
6. Perform a selection sort on the number grade array into descending order and output them again using functions.
I need some help on the last 3 questions of my assignment and I cannot figure out how to do it. Here's my code so far. I just don't know how to save them in an array etc. The code worked perfect before I tried to get the letter grade code working. I have no idea how to do this. Could someone help me or even better give me an example of something similar and explain it. I've been stuck on this for the past 4 hours.
#include <iostream>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;
//Global Function
void averageMaxCalc(int scoreInput[5], int sumZ, double& sAverage, double& sAverageF);
void studentScoreCalc(int scoreInput[5], int sum);//Function studentScore()
void deviation(int scoreInput[5], int sum);
int letterGradesA(int scoreInput[5], char letterDefined);
//|=======================|
//|======== Main =========|
//|=======================|
int main (char LetterDefined)
{
cout << "Welcome to the student score calculator program.\n\n";
//Variables
int scoreInput[5], sum = 0, sumZ = 0;
double sAverage, sAverageF;
//Defined
char letterDefined;
char letterGrades[6];
for (int m = 0; m < 6; ++m)
{
letterDefined = letterGrades[m];
}
//Functions Within Main()
studentScoreCalc(scoreInput, sum);//Function StudentScore()
averageMaxCalc(scoreInput, sumZ, sAverage, sAverageF);//Function averageMaxCalc()
deviation(scoreInput, sum);//Function deviation()
//letterGradesA() returned
letterGradesA(scoreInput, letterDefined);
system("pause");
return 0;
}
//|=====================================|
//|=== 1. Student Input and Max/Less ===|
//|=====================================|
void studentScoreCalc(int scoreInput[5], int sum)
{
//Declearing Variables
sum = 0;
cout << "Please Enter Student Scores below: \n";//Outputs to Console
//Sum is set to 0
//Looping countScore and i 15x
for (int i = 0; i <5; i++)
{
cin >> scoreInput[i];//Creates User Input
}
}
//|=================================|
//|=== 2. Funtion averageMaxCalc ===|
//|=================================|
void averageMaxCalc(int scoreInput[5], int sumZ, double& sAverage, double& sAverageF)
{
sumZ = 0;//Set sumZ to 0;
//Gets Sum Of All Numbers
sumZ = scoreInput[0]+scoreInput[1]+scoreInput[2]+scoreInput[3]+scoreInput[4];
//Finds The Average
sAverage = sumZ / 5;//Finds Average
sAverageF = (sumZ%5)*2;//Finds Decimal
cout << "The Sum Of All Scores Is: " <<sumZ << "\n"
<< "The Average Is: " << sAverage << "." << sAverageF << endl;
}
//|===================================|
//|=== 3. Calculation of Deviation ===|
//|===================================|
void deviation(int scoreInput[5], int sum)
{
double eX2Input;
double eXInput;
double variance;
double sDeviation;
//Gets EX^2
eX2Input = pow(scoreInput[0], 2) + pow(scoreInput[1], 2) + pow(scoreInput[2], 2) + pow(scoreInput[3], 2) + pow(scoreInput[4],2);
eXInput = scoreInput[0] + scoreInput[1] + scoreInput[2] + scoreInput[3] + scoreInput[4];
variance = (5*(eX2Input)-(eXInput))/(5 * (5-1));//Calculates Variance
sDeviation = sqrt(variance);//Calculates Standard Deviation
//Testing output
cout << "The Standard Deviation is: " << sDeviation << endl;
}
//|===============================================|
//|======= 4. Grades Converted To Letters ========|
//|===============================================|
int letterGradesA(int scoreInput[5], char letterDefined)
{
if(scoreInput[0] <= 100)
scoreInput[0] = 'A';
else if(scoreInput[0] < 90)
scoreInput[0] = 'B';
else if(scoreInput[0] < 80)
scoreInput[0] = 'C';
else if(scoreInput[0] < 70)
scoreInput[0] = 'D';
else if(scoreInput[0] < 60)
scoreInput[0] = 'F';
if(scoreInput[1] <= 100)
scoreInput[1] = 'A';
else if(scoreInput[1] < 90)
scoreInput[1] = 'B';
else if(scoreInput[1] < 80)
scoreInput[1] = 'C';
else if(scoreInput[1] < 70)
scoreInput[1] = 'D';
else if(scoreInput[1] < 60)
scoreInput[1] = 'F';
if(scoreInput[2] <= 100)
scoreInput[2] = 'A';
else if(scoreInput[2] < 90)
scoreInput[2] = 'B';
else if(scoreInput[2] < 80)
scoreInput[2] = 'C';
else if(scoreInput[2] < 70)
scoreInput[2] = 'D';
else if(scoreInput[2] < 60)
scoreInput[2] = 'F';
if(scoreInput[3] <= 100)
scoreInput[3] = 'A';
else if(scoreInput[2] < 90)
scoreInput[3] = 'B';
else if(scoreInput[2] < 80)
scoreInput[3] = 'C';
else if(scoreInput[2] < 70)
scoreInput[3] = 'D';
else if(scoreInput[2] < 60)
scoreInput[3] = 'F';
if(scoreInput[4] <= 100)
scoreInput[4] = 'A';
else if(scoreInput[2] < 90)
scoreInput[4] = 'B';
else if(scoreInput[2] < 80)
scoreInput[4] = 'C';
else if(scoreInput[2] < 70)
scoreInput[4] = 'D';
else if(scoreInput[2] < 60)
scoreInput[4] = 'F';
char letterGrade[][6] = {'A', 'B', 'C', 'D', 'F'};
return letterGradesA(scoreInput, letterDefined);
}

New Topic/Question
Reply



MultiQuote



|