Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.09 KB | None | 0 0
  1. /********************************
  2.  
  3. *grades4.c
  4.  
  5. *Date: 2018/02/22
  6.  
  7. ********************************/
  8. #include <stdio.h>
  9.  
  10.  
  11.  
  12. int main()
  13. {
  14.     //Function Prototype section
  15.     void banner();
  16.     int getNumberOfAssignments();
  17.     double getMaximumScore();
  18.     void getScores(double* lfScores, int iNumberOfAssignments);
  19.     void calculatedPercentagesAndGrades(
  20.         double* lfScores,
  21.         int iNumberOfAssignments,
  22.  
  23.         double* percentages,
  24.         char* grades
  25.     );
  26.     void print();
  27.     void process();
  28.     void test();
  29. //
  30.     int iNumberOfAssignments;
  31.     double lfMaxScore;
  32.     double lfScores[20];
  33.     double lfPercentages[20];
  34.  
  35.     test();
  36.     return 0;
  37. }
  38. //Function Definition section
  39. void banner()
  40. {
  41.     printf("Welcome to COP2220 Grading system\n===========================\n");
  42. }
  43. int getNumberOfAssignments()
  44. {
  45.     do {
  46.         printf("Enter the number of assignments to be graded: ");
  47.         scanf(" %d",&iNumberOfAssignments);
  48.     } while(iNumberOfAssignments <= 0 || iNumberOfAssignments > 20);
  49. }
  50. double getMaximumScore()
  51. {
  52.     do {
  53.         printf("Enter the maximum possible score in the assignments: ");
  54.         scanf(" %lf", &lfMaxScore);
  55.  
  56.     } while(lfMaxScore <= 0);
  57. }
  58. void getScores(double* pScores, int iNumberOfAssignments)
  59. {
  60.     for(int i = 0; i < iNumberOfAssignments; i++) {
  61.         do {
  62.             printf("Enter score for assignment %d: ",i);
  63.             scanf(" %lf", &lfScores[i]);
  64.         } while(lfScores[i] < 0 || lfScores[i] > lfMaxScore);
  65.     }
  66. }
  67. void calculatedPerecentagesAndGrades(
  68.     double* scores,          //Input parameter (an array)
  69.     int numberOfAssignments, //Input parameter (number of
  70.     // valid entries in the array)
  71.     double* lfPercentages,     //Output parameter (an array)
  72.     char* cGrades            //Output parameter (an array)
  73. )
  74. {
  75.     for(int i = 0; i < iNumberOfAssignments; i++) {
  76.         lfPercentages[i] = lfScores[i] / lfMaxScore * 100
  77.  
  78.     }
  79. }
  80. void test()
  81. {
  82.     banner();
  83.     getNumberOfAssignments();
  84.     getMaximumScore();
  85.     getScores(lfScores, iNumberOfAssignments);
  86.  
  87. }
  88.  
  89. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement