i want to make a c++ program in which we can only use if and else if and else to calculate GPA of students
i was thinking that string is going to be use and i want to know is there any way i can use string like this
1 2 3 4 5 6
string str1;
str1="A grade";
if (a=>85)
{
a=str1
}
i just want to find out how to do this i mean if a satisfy the condition then he safe a string value in it
output should be like this
S.# Subject Obt Marks Per (%) Grade GPA Remarks
1 Programming 87 87 A 4 Excellent
2 Calculus 82 82 A- 3.75 Very Good
3 English 76 76 B+ 3.50 Good
4 Computing 70 70 B 3.0 Satisfactory
GPA: 3.59
obt marks= obtained marks
per= percentage
table
S.# Percentage (%) Grade GPA Remarks
1 85-100 A 4 Excellent
2 80-84 A- 3.75 Very Good
3 75-79 B+ 3.50 Good
4 70-74 B 3.0 Satisfactory
5 65-69 C+ 2.50 Above Average
6 60-64 C 2.0 Average
7 55-59 D+ 1.50 Pass
8 50-54 D 1.0 Just Pass
9 Below 50 F 0 Fail
Your purpose is to calculate the GPA and not the grade. Hence you should use float instead of string. For instance if NUM_SUBJECTS is the number of subjects you can do something like:
1 2 3 4 5 6 7 8 9
float GPA[NUM_SUBJECTS];
for (int i = 0; i<NUM_SUBJECTS; i++) {
if (Percentage[i] > 85) // Percentage[i] contains percent marks obtained in 'i'th subject.
GPA[i] = 4;
elseif ..... // similarly for other conditions
}
/* after filling up the GPA array, i think you will also need to calculate the final GPA.
For this you will have to again loop through each element and calculate it as per the rules.
(a weighted average maybe)*/
is there any way i can get a+ if user enter 85 then any variable safe a+ but not print it on screen later i want to print it so in the end i can get the table form answer for user i have to safe all the data in different variable and then in the last it all have to be print on screen