I am working on displaying student name, test score, average marks and grade as an output.
This is what I have been working on, but still I couldn't manage to display the output.. The input must be get from the user and, which is the student name and the test score.
#include <conio>
#include <iostream>
void calculateAverage(int&);
char calculateGrade(int&, char&);
void main()
{
int avg, avrge;
char gd;
string stdntName;
cout <<"Enter the student name: "<<endl;
cin >> stdntName;
cout << "\nStudent name is: " << stdntName<<endl;
calculateAverage(avg);
cout << "The average marks are :/n " << avg <<endl;
calculateGrade(avrge,gd);
cout <<"Grade is : "<< gd<<endl;
}
void calculateAverage(int& average)
{
int sum=0,score;
cout<< "Enter all of the test score: " << endl;
for (int i = 0; i <5; i++)
cin >> score;
cout << score;
sum = sum + score;
average = sum/5;
}
char calculateGrade(int& avrg, char& grade)
{
if (avrg >=90 && avrg <=100)
grade = 'A';
else
if (avrg >=80 && avrg <= 89)
grade = 'B';
else
if (avrg >= 70 && avrg <= 79)
grade = 'C';
else
if (avrg >= 60 && avrg <= 69)
grade = 'D';
else
if (avrg >= 59)
grade = 'F'; //determine grade
return grade;
}
I know there's something wrong with this coding, because I didn't manage to produce the output, eventhough, there's no error while compiling. Do help me please. Need to submit it by tomorrow. thanks