Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************
- *grades4.c
- *Date: 2018/02/22
- ********************************/
- #include <stdio.h>
- int main()
- {
- //Function Prototype section
- void banner();
- int getNumberOfAssignments();
- double getMaximumScore();
- void getScores(double* lfScores, int iNumberOfAssignments);
- void calculatedPercentagesAndGrades(
- double* lfScores,
- int iNumberOfAssignments,
- double* percentages,
- char* grades
- );
- void print();
- void process();
- void test();
- //
- int iNumberOfAssignments;
- double lfMaxScore;
- double lfScores[20];
- double lfPercentages[20];
- test();
- return 0;
- }
- //Function Definition section
- void banner()
- {
- printf("Welcome to COP2220 Grading system\n===========================\n");
- }
- int getNumberOfAssignments()
- {
- do {
- printf("Enter the number of assignments to be graded: ");
- scanf(" %d",&iNumberOfAssignments);
- } while(iNumberOfAssignments <= 0 || iNumberOfAssignments > 20);
- }
- double getMaximumScore()
- {
- do {
- printf("Enter the maximum possible score in the assignments: ");
- scanf(" %lf", &lfMaxScore);
- } while(lfMaxScore <= 0);
- }
- void getScores(double* pScores, int iNumberOfAssignments)
- {
- for(int i = 0; i < iNumberOfAssignments; i++) {
- do {
- printf("Enter score for assignment %d: ",i);
- scanf(" %lf", &lfScores[i]);
- } while(lfScores[i] < 0 || lfScores[i] > lfMaxScore);
- }
- }
- void calculatedPerecentagesAndGrades(
- double* scores, //Input parameter (an array)
- int numberOfAssignments, //Input parameter (number of
- // valid entries in the array)
- double* lfPercentages, //Output parameter (an array)
- char* cGrades //Output parameter (an array)
- )
- {
- for(int i = 0; i < iNumberOfAssignments; i++) {
- lfPercentages[i] = lfScores[i] / lfMaxScore * 100
- }
- }
- void test()
- {
- banner();
- getNumberOfAssignments();
- getMaximumScore();
- getScores(lfScores, iNumberOfAssignments);
- }
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement