Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include <stdbool.h>
- #ifdef _MSC_VER
- #define _CRT_SECURE_NO_WARNINGS
- #endif
- bool VaildInputCheck(bool Threshold, int A, int B, int C)
- {
- Threshold = 0;
- //If the values inputed for each variable are over 100 or under 0, it will say if it's true or false with this
- if (A < 100 && B < 100 && C < 100 && A > 0 && B > 0 && C > 0 && A > B && B > C)
- {
- Threshold = 1;
- printf("\nThe threshold you have entered is valid. \n");
- }
- else
- {
- Threshold = 0;
- printf("\nThe threshold you have entered is not valid. \n");
- }
- return Threshold;
- }
- char FinalGradeOutput(char FinalGrade, int InputScore, int A, int B, int C, bool VaildInputCheck)
- {
- if (VaildInputCheck == 0)
- FinalGrade = 'N';
- else
- {
- if(InputScore >= A)
- FinalGrade = 'A';
- else if (InputScore >= B && InputScore < A)
- FinalGrade = 'B';
- else if (InputScore >= C && InputScore < B)
- FinalGrade = 'C';
- else if (InputScore < C)
- FinalGrade = 'F';
- }
- return FinalGrade;
- }
- int main()
- {
- char FinalGrade;
- int InputScore, A, B, C;
- bool Threshold;
- Threshold = 0;
- //Obtaining the values of the threshhold to determine if valid
- printf("\nEnter the threshold for grade A: ");
- scanf("%d", &A);
- printf("\nEnter the threshold for grade B: ");
- scanf("%d", &B);
- printf("\nEnter the threshold for grade C: ");
- scanf("%d", &C);
- printf("\nEnter the student grade: ");
- scanf("%d", &InputScore);
- //Function evaluates inputs to determine the grade and validity of previous value
- bool valid = VaildInputCheck(Threshold, A,B,C);
- //FinalGrade = FinalGradeOutput(FinalGrade, InputScore, A, B, C, valid);
- printf("\nYour final grade is: %c \n", FinalGradeOutput(FinalGrade, InputScore, A, B, C, valid));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement