-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
C++ Classes Introduction.cpp
66 lines (66 loc) · 1.39 KB
/
C++ Classes Introduction.cpp
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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
CollegeCourse cc;
string courseId;
int gp;
char grade;
int credits;
cin>>courseId>>grade>>credits;
cc.set_CourseId(courseId);
cc.set_Grade(grade);
cc.set_Credit(credits);
gp=cc.calculateGradePoints(grade);
cc.calculateHonorPoints(gp,credits);
cc.display();
}
return 0;
}
class CollegeCourse
{
public:
string courseId;
int gp;
char grade;
int credits;
void set_CourseId(string CID)
{
courseId=CID;
}
void set_Credit(int cr )
{
credits=cr;
}
void set_Grade(char g)
{
grade=g;
}
int calculateGradePoints(char g)
{
int gradePoint;
if(grade>=65 && grade<=90)
{
gradePoint=10+grade-65 ;
}
if(grade>=97 && grade<=102){
gradePoint=10-(grade-97);
}
return gradePoint;
}
int calculateHonorPoints(int gp,int cr)
{
int honorPoint;
honorPoint=cr*calculateGradePoints(gp);
return honorPoint;
}
void display()
{
cout<<calculateGradePoints(grade)<<" ";
cout<<calculateHonorPoints(gp,credits)<<endl;
}
};