URGENT!!! i have prob on struct n array.. need handin in few hours.. help

PLEASE..........i've been tried this for 2 days..

Write a program to calculate the grade point average (CGPA) of the student. Students are required to enter the course and the grade of the subjects taken and the next program will calculate CGPA received by students. Make sure students include data for at least two semesters for the purpose of this calculation of CGPA. For each semester, show the calculation of the overall grade obtained.
Your program should use a structure concepts to students and using the concept of arrays for the subjects taken.

semester1
MTS3013 structure programming
MTK3013 structure disckrit
MTN3013 computer organization and architecture

SEMESTER2
MTS3033 OBJECKT ORIENTED PROGRAMMING
MTN3023 NETWORKING
MTD3033 DATABASE SYSTEM

if (gred=='A')
cout<<"4.00";
else if (gred=='A-')
cout<<"3.75";
else if (gred=='B+')
cout<<"3.50";
else if (gred=='B')
cout<<"3.00";
else if (gred=='B-')
cout<<"2.75";
else if (gred=='C+')
cout<<"2.50";
else if (gred=='C')
cout<<"2.00";
else if (gred=='C-')
cout<<"1.75";
else if (gred=='D+')
cout<<"1.50";
else if (gred=='D')
cout<<"1.00";
else (gred=='F')
cout<<"0.00";
Dont post ur assignments over here... Show some effort and we will help you ... you are trying to have spoon feeding
i'm not trying to have spoon feeding..

i'm asking for help..

if there anyone want to help by show me the coding..

i'll compare it with what i've done, then, i'll redo it based on my understanding and try to understand more

TQ..
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
99
100
101
102
103
104
105
106
107
108
109
110

#include<iostream.h>		// for inpit and output
#include<string.h>		// for string nama...
using namespace std;		// for name space..

struct student	// declare struct
{
	string name,no_matric;
	string sub_code[10],sub_name[10],sub_grade[10];
	float credit_hour[10];
}student1;

main()
{
	int credit_hours[10];
	int sem,total_subject;		//'b', 'a',total_credit_hours and total_point 
//are removed
	float value[10],gpa[10],get_point[10];
	float cgpa;
	float total_point_sem = 0; 		//Initialise value
	int total_credit_hours_sem = 0; 	//Initialise value
	cin.ignore();
	
	cout << "\t\ ================ ";
	cout << "\n\t\ STUDENT'S REKOD " << endl;
	cout << "\t\ ================ " << endl;
	
	cout << "\n ENTER STUDENT'S NAME	: ";		//Enter student's name
	getline(cin,student1.name);
	cout << " ENTER STUDENT'S MATRIC NUMBER  : "; 		//Enter student's matric number
	getline(cin,student1.no_matric);
	cout << " ENTER TOTAL SEM TAKEN	:"; 		//Total semester taken by the student
	cin >> sem;
	
	for(int a = 0; a< sem ; a++) 	//'a' declared as int in for()[newly added]
	{ 
		int b;  //newly added line,'b' choose to add it here because, if not, error will be occured : 'b' for gpa[b] will become undefined...

		int total_credit_hours = 0;		//newly added
		float total_point = 0; 		//newly added
		cout << "\n ENTER SUBJECT TAKEN FOR SEM	 : " << a+1 << ":"; //Enter total number of subject taken for each sem
		cin >> total_subject;
		for(int b = 0; b< total_subject; b++) //loop for the courses
		{
			cin.ignore();
			cout << " ENTER SUBJECT CODE	: ";  //Enter subject code
			getline(cin,student1.sub_code[b]);
			cout << " ENTER SUBJECT NAME	: ";  //Enter subject name
			getline(cin,student1.sub_name[b]);
			cout << " ENTER SUBJECT'S CREDIT HOUR	: ";  //Enter credit hours of the subject
			cin >> student1.credit_hour[b];
			cin.ignore();
			cout << " ENTER SUBJECT GRED	: ";  //Enter grade gained by student for every subject
			getline(cin,student1.sub_grade[b]);
			
			if(student1.sub_grade[b]=="A")
				value[b]=4;
			else if(student1.sub_grade[b]=="A-")
				value[b]=3.75;
			else if(student1.sub_grade[b]=="B+")
				value[b]=3.5;
			else if(student1.sub_grade[b]=="B")
				value[b]=3;
			else if(student1.sub_grade[b]=="B-")
				value[b]=2.75;
			else if(student1.sub_grade[b]=="C+")
				value[b]=2.5;
			else if(student1.sub_grade[b]=="C")
				value[b]=2;
			else if(student1.sub_grade[b]=="C-")
				value[b]=1.75;
			else if(student1.sub_grade[b]== "D+")
				value[b]=1.5;
			else if(student1.sub_grade[b]=="D")
				value[b]=1;
			else 
				value[b]=0;
			
			get_point[b] = student1.credit_hour[b] * value[b]; //multiply of credit hours and grade get for each subject
			total_credit_hours +=student1.credit_hour[b]; //total cerdit hours for a sem
			total_point += get_point[b]; //total points(multiple of credits hours and grade)get for a sem 
		}
		
		gpa[b] = total_point / total_credit_hours; //calculate GPA for each sem
		
		total_point_sem += total_point; //Total points(multiple of grade and credit hours) get for all semester
		
		total_credit_hours_sem += total_credit_hours; //credits hour get for all semester
	}
	
	cgpa = total_point_sem / total_credit_hours_sem;  //calculate CGPA
	
	cout << "\n =================================================== ";
	cout <<"\n NAME			: " << student1.name << endl;  //display name of student
	cout <<" NO MATRIC	: "<< student1.no_matric << endl;
	for(int a = 0; a< sem ; a++) //Declaration of 'a' as int in for()
	{ 
		cout <<" SUBJECT CODE \t" << " SUBJECT NAME \t" << " SUBJECT CREDIT HOURS " <<endl;
		for(int b=0; b<total_subject; b++) //Declaration of 'b' as int in for()
		{
			cout << " " << student1.sub_code[b] << " : " << student1.sub_name[b]<< " : " << student1.credit_hour[b] << endl;
		}
			cout << " GPA" <<a+1<< " : " <<gpa[a] << endl; 
	} 
			cout << " CGPA : "<<cgpa<<endl;
	
		cout << "\n =================================================== ";

}
Stating exactly what the problem you're experiencing is would be a good start. ;-)
Topic archived. No new replies allowed.