In: Computer Science
Suppose you are writing a program to compute the semester GPA for a person based on knowing the grades earned and the number of credit hours for each course taken.
What type of tests would you need to create to check that your program was working correctly? Be specific, and remember to keep in mind tests that might contain unexpected input. How would your program react to those?
After you have made your post, you need to provide thoughtful comments on at least two other posts (or replies).
Your original post is due Sep 8; your replies are due Sep 11.
In order to test a program, we must know how to calculate GPA from grades and credit hours.
Following is the common grades according to Grade point achieved.
Grade Point |
Grade |
4.00 |
A+ |
3.67 |
A- |
3.33 |
B+ |
3.00 |
B |
2.67 |
B- |
2.33 |
C+ |
2.00 |
C |
1.00 |
D |
0.00 |
F |
From the grades of subjects, grade points are taken using above table
Subject |
Grades |
Credit Hours |
GradePoint |
English |
A+ |
2 |
4.00 |
EVS |
B |
3 |
3.00 |
Maths |
C+ |
4 |
2.33 |
to calculate GPA from credit hours, Credit hours is multiplied with GradePoint to get GP
Subject |
Grades |
Credit Hours |
GradePoint |
GP |
English |
A+ |
2 |
4.00 |
8.00 |
EVS |
B |
3 |
3.00 |
9.00 |
Maths |
C+ |
4 |
2.33 |
9.32 |
Sum |
9 |
26.32 |
GPA = Sum of GP/sum of credit Hours
= 26.32/9
=2.92
Algorithm to calulate GPA
Display “Invalid Input
Exit program
End if
Display “Invalid Input
Exit program
End if
Display “Invalid Input
Exit program
End if
Funtion checkgrade(grade)
If grade==”A+”
return 4.00
else if grade==”A-“
return 3.67
else if grade==”B+”
return 3.33
else if grade==”B”
return 3.00
else if grade==”B-“
return 2.67
else if grade==”C+”
return 2.33
else if grade== “C”
return 2.00
else if grade==”D”
return 1.00
else if grade== “F”
return 0.00
else
return -1
End If
End Function
Types of testing
For GPA program
Example : A simple value change such as 2.34 instead of 2.33 for “C+” will give wrong results
Some examples of unexpected inputs:
This can be dealt using extra else and returning some exit value which is checked and program exits as shown in algorithm.