How do i connect for this two function??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//3.A void function to calculate total points and GPA for one student
void Calculate_GP(float count, int Units)
{	
	float Total_Point;
	int Sum = 0;
	
	Sum += Units;
	Total_Point += count;
	if(Counter > 0)
		Average = Total_Point/Sum;
	else
		Average = 0;
	return;
}


//2.float function to assign GPA points based on a grade

//read Grade and Units
float Read_GU(ifstream &fin,char &Grade,int &Units)
{
	float gpa,count=0,Total_count = 0,Average;
	int Sum = 0,Counter=0;
	fin >> Grade >> Units;
	while(Grade != '*')
	{	
		if(Grade == 'A' || Grade == 'a')
			gpa = 4.0;
		else if (Grade == 'B' || Grade == 'b')
			gpa = 3.0;
		else if (Grade == 'C' || Grade == 'c')
			gpa = 2.0;
		else if (Grade == 'D' || Grade == 'd')
			gpa = 1.0;
		else if (Grade == 'F' || Grade == 'f')
			gpa = 0;
		else
		gpa = -1 ;
		if (Units == 1)
			count  = gpa * Units;
		else if (Units == 2)
			count = gpa * Units;
		else if (Units == 3)
			count = gpa * Units;
		else if (Units == 4)
			count = gpa * Units;
		else if (Units == 5)
			count = gpa * Units;
		else 
			count = 0;
		if(Units > 0 && Units < 5)//check units
		{
			fin >> Grade >> Units;
			//cout << StudentID << Grade << Units;
		}
		else if(Units > 5)
		{
			Units = 0;
			fin >> Grade >> Units;
		}
		Sum += Units;
		Total_count += count;
		Counter ++;
		fin.ignore(100,'\n');
	}
	if (Counter > 0)
		Average = Total_count/ Sum;
		//cout << "your total is" << Average << endl;
	else 
		Average = 0;
	return Average;
}
Topic archived. No new replies allowed.