Assignment
Assignment
I. INTRODUCTION
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
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();
n++;
}
printf("GPA=%.2f\n",total/totalc);
printf("\nCPA calculator\n");
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
IV. CONCLUSION