Can't find the way to work with array to find cgpa from the grade that user have been enter

The question is, write a program to find cgpa for a student, the student need to enter their name, matrix num, subjects name and grades for each subject. Then the program will display the cgpa for the semester, the program required student to enter data for minimum two semester and lastly, the program will display the average cgpa for the semesters. The program should used struct for student and array for the subjects. Here is my half code, i stuck when it comes to use an array to get the grades and convert it to grades value. Is any solution for my problems?

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* Assignment 2 
To find GPA is computed by dividing the total number of grade points earned by 
the total number of credit hours of work completed during the semester.

To find the cgpa  is computed by dividing the total number of grade points 
earned by the total number of credit hours cmpleted by the student

*/

#include<iostream>
#include<string>
using namespace std;

struct student
{
string name;
string id_num;
string sub_name;
int c_hour;
string gred;	
}info,subject;

void get_subject();
void calculate();

int main()
{
int sub_num;
int sem;
cout<<"*******Program To Calculate Student PNGS *********"<<endl;
cout<<endl<<"Enter student name:";
cin.ignore();
getline(cin,info.name);	
cout<<"Enter Matrix N.o:";
getline(cin,info.id_num);

do
{
cout<<endl<<"Enter semester, otherwise enter 0 to exit:";
cin>>sem;
if(sem>0)
get_subject();
else
cout<<endl<<"Program closed!! Bye2";
	
}while(sem!=0);


}

void get_subject()
{
int sub_num;
cout<<"How many subjects:";
cin>>sub_num;
for(int x=0;x<sub_num;x++)
{
cout<<endl<<"Name of Subject:";
cin.ignore();
getline(cin,subject.sub_name);
cout<<"Credit Hour:";
cin>>subject.c_hour;
cout<<"Gred:";
cin.ignore();
getline(cin,subject.gred);

}
}

void calculate() //dont know how to implement this 
{
int grade;
if(subject.gred=="A"||subject.gred=="a")
grade=4.00;
else if(subject.gred=="A-"||subject.gred=="a-")
grade=3.75;
else if(subject.gred=="B+"||subject.gred=="b+")
grade=3.50;
else if(subject.gred=="B"||subject.gred=="b")
grade=3.00;
else if(subject.gred=="B-"||subject.gred=="b-")
grade=2.75;
else if(subject.gred=="C+"||subject.gred=="c+")
grade=2.5;
else if(subject.gred=="C"||subject.gred=="c")
grade=2.00;
else if(subject.gred=="C-"||subject.gred=="c")
grade=1.75;
else if(subject.gred=="D+"||subject.gred=="d+")
grade=1.5;
else if(subject.gred=="D"||subject.gred=="d")
grade=1.00;
else
grade=0;
}


Topic archived. No new replies allowed.