Advertisement
Guest User

project

a guest
Dec 5th, 2019
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.89 KB | None | 0 0
  1. // Octavio Lucca, 120888193
  2.  
  3. //final Project PRG 12/05/2019 5:00pm
  4.  
  5.  
  6. #include <stdio.h>
  7. void explain(int counterA, int counterB, int counterC, int counterF, float avg);
  8. #define A_RANGE "(85-100)"
  9. #define B_RANGE "(70-84)"
  10. #define C_RANGE "(55-69)"
  11. #define F_RANGE "(0-54)"
  12. #define A_START 85
  13. #define B_START 70
  14. #define C_START 55
  15. //above is all defining and plus the function
  16. void main()
  17. {
  18.     float mark = 0, avg = 0, sum = 0, countermark = 0; //giving values
  19.     int counterA = 0, counterB = 0, counterC = 0, counterF = 0; //giving values
  20.  
  21.     do//while number different then 999 keep looping forever
  22.     {
  23.         explain(counterA, counterB, counterC, counterF, avg); // giving values tand calling the function
  24.         scanf("%f", &mark); //scanning what mark the user is imputing
  25.         if (mark <= 100 && mark >= 0) //checking if mark is going to add to our mark range (A to F)
  26.         {
  27.             countermark++; //counting how many marks are beeing added to be used on the avarage
  28.             if (mark >= A_START) // checking if mark is betting A range
  29.             {
  30.                 counterA++;//adding +1 to A_range in the printf
  31.             }
  32.             else if (mark >= B_START&&mark<A_START)// checking if mark is betting B range
  33.             {
  34.                 counterB++;//adding +1 to B_range in the printf
  35.             }
  36.             else if (mark >= C_START&&mark<B_START)// checking if mark is betting C range
  37.             {
  38.                 counterC++;//adding +1 to C_range in the printf
  39.             }
  40.             else if (mark<C_START&&mark >= 0)// checking if mark is betting F range
  41.             {
  42.                 counterF++;//adding +1 to F_range in the printf
  43.             }
  44.    
  45.             sum += mark;// sum = sum + mark
  46.             avg = sum / countermark; // avg = sum+=mark/countermark
  47.             system("cls");
  48.         }
  49.         else
  50.         {
  51.             printf("\ninvalid entry\n");
  52.             printf("\ninvalid entry\n");
  53.             printf("\ninvalid entry\n");
  54.         }
  55.         if (mark == -1) //to reset the grade counters
  56.         {
  57.             counterA = 0; //seting A to 0
  58.             counterB = 0;//seting B to 0
  59.             counterC = 0; //seting C to 0
  60.             counterF = 0; //seting F to 0
  61.  
  62.         }
  63.         else if (mark == 999) // confirming if the user wants to leave
  64.         {
  65.             printf("enter to confirm exiting the program");
  66.         }
  67.        
  68.        
  69.         getchar();
  70.  
  71.     } while (mark != 999);
  72.  
  73.  
  74.     getchar();
  75.  
  76. }
  77.  
  78. void explain(int counterA, int counterB, int counterC, int counterF, float avg) //getting the values of the mark from main
  79. {
  80.     printf("        GRADING SUMMARY\n");
  81.     printf("\nTotal number of 'A' %s \t%d ", A_RANGE, counterA);
  82.     printf("\nTotal number of 'B' %s \t%d ", B_RANGE, counterB);
  83.     printf("\nTotal number of 'C' %s \t%d ", C_RANGE, counterC);
  84.     printf("\nTotal number of 'F' %s \t%d ", F_RANGE, counterF);
  85.     printf("\n------------------------------------");
  86.     printf("\nThe average of marks entered = \t%.1f \n", avg);
  87.     printf("\nOPERATIONS: \n");
  88.     printf("\nEnter marks between 0 to 100 for the summary. \n");
  89.     printf("\nEnter -1 to clear all counters. ");
  90.     printf("\nEnter 999 to exit the program.\n");
  91.     printf("\nEnter one mark at a time from here ==> ");
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement