Sie sind auf Seite 1von 8

Assignment: GPA and CPA Calculator

I. INTRODUCTION

Where accumulated point =


In this assignment we are required to develop software to
calculate CPA and GPA (for current semester) calculator.
The input for software GPA calculator are credit counted For all semester.
and credit and grade for each subject. Besides that, input for
CPA calculator are previous semester’s accumulated points Pass or No Pass courses are not factored in the student's GPA.
and previous semester’s total credit counted. Incompletes and Withdrawals do not receive grade points and
The output of software are GPA for current semester and do not have an effect on the GPA. Therefore they are not
CPA. necessary to include in the calculation.
The function of this software is to help students to
understand and calculate their GPA and CPA.
Grade point average (GPA) is calculated by dividing the II. PROCEDURE
total amount of grade points earned by the total amount of
credit hours attempted.
MARKS GRADE GRADE POINT
The formula for GPA is:
80 - 100 A 4.00

75 - 79 A- 3.67

70 - 74 B+ 3.33

65 - 69 B 3.00

60 - 64 B- 2.67
Where G = Grade point
55 - 59 C+ 2.33
C = Couse credit hour (for credit counted
subjects only) 50 - 54 C 2.00

n = number of subjects taken 47 - 49 C- 1.67

Cumulative point average (CPA) is calculated by accumulated 44 - 46 D+ 1.33


point (summation of the multiplication of the grade points and
credit hours for all semester), divided by the accumulated 40 - 43 D 1.00
points by the total credit counted.
25 - 39 E 0.67
The formula for calculating CPA is: 0 - 24 F 0.00
TABLE I: grade and grade points in UMP
In this assignment we are required to use FUNTION.
Therefore I have used function ‘void grading()’, to display
the content of TABLE I for user to read and enter the choice
of number (represented the grade) he got for the subject.

On the other hand, I have used function, ‘float grade(int


g)’ in my program which is switch and case function to read
the users’ input of choice of number (represented the grade).
For example, choice of number (represented the grade) that printf("(3)70-74\tGRADE B+\t grade
user entered is 1, the function will read the grade point is point=3.33\n");
4.00. printf("(4)65-69\tGRADE B\t\t grade
First the C program will require the users to input number of point=3.00\n");
subjects taken. I have used ‘While’ in my C program in printf("(5)60- 64\tGRADE B-\t grade
order to repeat the loop (n) for user to enter the choice of point=2.67\n");
number (represented the grade) and credit hour for each printf("(6)55-59\tGRADE C+\t grade
subject, in the condition that the loop (n) <= number of point=2.33\n");
subjects entered. printf("(7)50-54\tGRADE C\t\t grade
point=2.00\n");
The operation for GPA calculator: (grade point times credit printf("(8)47-49\tGRADE C-\t grade
hour of the subject) represented by (sum=grade1*c), for point=1.67\n");
each subject. In order for the loop to repeat and add up the printf("(9)44-46\tGRADE D+\t grade
previous subject entered the operation is written as point=1.33\n");
‘total+=sum’. Then, the total(summation of grade point printf("(10)40-43\tGRADE D\t\t grade
times credit hour for each subject) it is divided by total point=1.00\n");
number of credit hour of current semester (totalc). printf("(11)25-39\tGRADE E\t\t grade
point=0.67\n");
The operation of CPA calculator: the user is required to printf("(12)0-24\tGRADE F\t\t grade
input previous semester’s accumulated points and previous point=0.00\n");
semester’s total credit counted. The previous semester’s }
accumulated points is added with the total (summation of
grade point times credit hour for each subject), then divided 11. Input:
by the summation of previous semester’s total credit printf("Please enter grade for subject %d\n",n);
counted and total number of credit hour of current semester 12. Read user entered choice of grade (eg: 1 or 2) for
(totalc). the subject
13. Function float grade(int g): to change the choice
of grade into grading
III. RESULTS 14. Operation: sum=grading*c;
15. Operation: total+=sum;
a) A pseudo-code for the given problem is shown below. 16. While loop to repeat, n++;}
17. Operation: total/totalc (summation of credit hour
times the grading divided by total credit hour)
1. Begin 18. Output:
2. printf("GPA CALCULATOR\n"); printf("GPA=%.2f\n");
3. Input: 19. printf("\nCPA calculator\n");
printf("Please enter Credit Counted:\n"); 20. Input:
4. Read user entered number for total credit hour printf("Please enter Previous semesters
5. Input: accumulated points=\n");
printf("Please enter number of subject 21. Read user entered Previous semesters
taken:\n"); accumulated points
6. Read user entered number of the subject 22. Input:
7. while(loop(n)<=subject) printf("Please enter Previous semesters total
{ credit counted=\n");
8. Input: 23. Read user entered Previous semesters
printf("Please enter credit hour for subject accumulated points
%d\n",n); 24. Operation: cpa=(previous_ap+total)/
9. Read user entered number for credit hour of the (previous_c+totalc);
subject 25. Output:
10. Funtion: grading(); (used to display the grading printf("CPA=%.2f",cpa);
for user to enter) }
{ 26. End
printf("(1)80-100\tGRADE A\t\t grade
point=4.00\n");
printf("(2)75-79\tGRADE A-\t grade
point=3.67\n");
b) The flowchart for the given problem is shown below.
c) Build a C program code using FUNCTION in the
program.

C program:

void grading();
float grade(int g);
int main()
{

int n=1,subject;
float c,sum,total,totalc,grade1;
float previous_ap,previous_c,cpa;
int g;
printf("GPA CALCULATOR\n");
printf("Please enter Credit Counted:\n");
scanf("%f",&totalc);
printf("Please enter number of subject taken:\n");
scanf("%d",&subject);

while(n<=subject)
{
printf("Please enter credit hour for subject %d\n",n);
scanf("%f",&c);
getch();

grading();

printf("Please enter grade for subject %d\n",n);


scanf("%d",&g);
grade1=grade(g);
sum=grade1*c;
total+=sum;

n++;
}
printf("GPA=%.2f\n",total/totalc);

printf("\nCPA calculator\n");

printf("Please enter Previous semesters accumulated


points=\n");
scanf("%f",&previous_ap);

printf("Please enter Previous semesters total credit


counted=\n");
scanf("%f",&previous_c);

cpa=(previous_ap+total)/(previous_c+totalc);

printf("CPA=%.2f",cpa);

return 0;
}
default:
void grading() grade=0;
{
printf("(4)65-69\tGRADE B\t\t grade point=3.00\n"); }
printf("(5)60- 64\tGRADE B-\t grade point=2.67\n"); return grade;
printf("(6)55-59\tGRADE C+\t grade point=2.33\n"); }
printf("(7)50-54\tGRADE C\t\t grade point=2.00\n");
printf("(8)47-49\tGRADE C-\t grade point=1.67\n");
printf("(9)44-46\tGRADE D+\t grade point=1.33\n"); d) For the results output, we are required to Test and verify
printf("(10)40-43\tGRADE D\t\t grade point=1.00\n"); the C program that has been built and illustrate the
printf("(11)25-39\tGRADE E\t\t grade point=0.67\n"); output for students’ transcript shown in Figure 2.
printf("(12)0-24\tGRADE F\t\t grade point=0.00\n");
getch();

float grade(int g)
{
float grade;
switch (g)
{
case 1:
grade=4.00;
break;
case 2:
grade=3.67;
break;
case 3:
grade=3.33;
break; FIGURE 2:Output for students’ transcript
case 4:
grade=3.00; Using the C program, the output for calculated GPA is 3.22.
break; The output for calculated CPA is 3.37.
case 5:
grade=2.67; The output of the program tested are shown below.
break;
case 6:
grade=2.33;
break;
case 7:
grade=2.00;
break;
case 8:
grade=1.67;
break;
case 9:
grade=1.33;
break;
case 10:
grade=1.00;
break;
case 11:
grade=0.67;
break;
case 12:
grade=0.00;
break;
IV. DISCUSSION

The CPA and GPA can be calculated using C program. By


using this, students can calculate their own GPA and CPA.
In building the C program, we are required to use the
function.
A function is a group of statements that together perform a
task. Every C program has at least one function, which
is main(), and all the most trivial programs can define
additional functions. We can divide up the code into
separate functions. Division usually is so each function
performs a specific task. A function declaration tells the
compiler about a function's name, return type, and
parameters. A function definition provides the actual body
of the function.
Thus, using function can make our C program looked neat
and easy for correction and justification.
While loop is used for the purpose of repetition, to repeat
the loop for the user to enter the credit hour and grade for
each subjects.
In addition, switch and case is used in the C programming.
A switch statement allows a variable to be tested for
equality against a list of values. Each value is called a case,
and the variable being switched on is checked for
each switch case. When the variable being switched on is
equal to a case, the statements following that case will
execute until a break statement is reached. When
a break statement is reached, the switch terminates, and the
flow of control jumps to the next line following the switch
statement. Switch and case is used for the user to enter the
choice of grade and then show that grade point of the choice
entered.

IV. CONCLUSION

By completing this assignment, I am able to identify the


basic principles and concept of computer programming to
solve the basic problem with utilization the knowledge of
mathematics and sciences.

Das könnte Ihnen auch gefallen