/*Group members:
Saharulnizam Hakimy bin Shobri
A19EC0205
Chee Wai Lum
A19EC0032*/
#include<iostream>
using namespace std;

void calc(int, int, int&, double&);

int main(){
	
	int numAss, mark, sum;
	double average;
	
	//getting assessment's number
	cout<<"Enter the number of assessment: ";
	cin>>numAss;
	
	//loop for getting the mark for each assessment
	for(int i=1; i<=numAss; i++){
	loop:	cout<<"Enter mark of assessment "<<i<<" (between 1-100): ";
			cin>>mark;
			
			//check if input is valid or not
			if((mark<0)||(mark>100)){
				goto loop;}
			
			//calling fx
			calc(numAss, mark, sum, average);
	}
	
	//print out the result
	if((average<=100)&&(average>=90))
		cout<<"The grade is A";
	else if(average>=80)
		cout<<"The grade is B";
	else if(average>=70)
		cout<<"The grade is C";
	else if(average>=60)
		cout<<"The grade is D";
	else if(average>=0)
		cout<<"The grade is F";
		
	return 0;
}

void calc(int numAss, int mark, int& sum, double& average){
	
	//calculate the sum and average
	sum+=mark;
	average=sum/numAss;
}

