Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Octavio Lucca, 120888193
- //final Project PRG 12/05/2019 5:00pm
- #include <stdio.h>
- void explain(int counterA, int counterB, int counterC, int counterF, float avg);
- #define A_RANGE "(85-100)"
- #define B_RANGE "(70-84)"
- #define C_RANGE "(55-69)"
- #define F_RANGE "(0-54)"
- #define A_START 85
- #define B_START 70
- #define C_START 55
- //above is all defining and plus the function
- void main()
- {
- float mark = 0, avg = 0, sum = 0, countermark = 0; //giving values
- int counterA = 0, counterB = 0, counterC = 0, counterF = 0; //giving values
- do//while number different then 999 keep looping forever
- {
- explain(counterA, counterB, counterC, counterF, avg); // giving values tand calling the function
- scanf("%f", &mark); //scanning what mark the user is imputing
- if (mark <= 100 && mark >= 0) //checking if mark is going to add to our mark range (A to F)
- {
- countermark++; //counting how many marks are beeing added to be used on the avarage
- if (mark >= A_START) // checking if mark is betting A range
- {
- counterA++;//adding +1 to A_range in the printf
- }
- else if (mark >= B_START&&mark<A_START)// checking if mark is betting B range
- {
- counterB++;//adding +1 to B_range in the printf
- }
- else if (mark >= C_START&&mark<B_START)// checking if mark is betting C range
- {
- counterC++;//adding +1 to C_range in the printf
- }
- else if (mark<C_START&&mark >= 0)// checking if mark is betting F range
- {
- counterF++;//adding +1 to F_range in the printf
- }
- sum += mark;// sum = sum + mark
- avg = sum / countermark; // avg = sum+=mark/countermark
- system("cls");
- }
- else
- {
- printf("\ninvalid entry\n");
- printf("\ninvalid entry\n");
- printf("\ninvalid entry\n");
- }
- if (mark == -1) //to reset the grade counters
- {
- counterA = 0; //seting A to 0
- counterB = 0;//seting B to 0
- counterC = 0; //seting C to 0
- counterF = 0; //seting F to 0
- }
- else if (mark == 999) // confirming if the user wants to leave
- {
- printf("enter to confirm exiting the program");
- }
- getchar();
- } while (mark != 999);
- getchar();
- }
- void explain(int counterA, int counterB, int counterC, int counterF, float avg) //getting the values of the mark from main
- {
- printf(" GRADING SUMMARY\n");
- printf("\nTotal number of 'A' %s \t%d ", A_RANGE, counterA);
- printf("\nTotal number of 'B' %s \t%d ", B_RANGE, counterB);
- printf("\nTotal number of 'C' %s \t%d ", C_RANGE, counterC);
- printf("\nTotal number of 'F' %s \t%d ", F_RANGE, counterF);
- printf("\n------------------------------------");
- printf("\nThe average of marks entered = \t%.1f \n", avg);
- printf("\nOPERATIONS: \n");
- printf("\nEnter marks between 0 to 100 for the summary. \n");
- printf("\nEnter -1 to clear all counters. ");
- printf("\nEnter 999 to exit the program.\n");
- printf("\nEnter one mark at a time from here ==> ");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement