Advertisement
Guest User

dad

a guest
Jun 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include "stdio.h"
  2. #include <stdbool.h>
  3. #ifdef _MSC_VER
  4. #define _CRT_SECURE_NO_WARNINGS
  5. #endif
  6.  
  7.  
  8. bool VaildInputCheck(bool Threshold, int A, int B, int C)
  9. {
  10.     Threshold = 0;
  11.     //If the values inputed for each variable are over 100 or under 0, it will say if it's true or false with this
  12.     if (A < 100 && B < 100 && C < 100 && A > 0 && B > 0 && C > 0 && A > B && B > C)
  13.     {
  14.     Threshold = 1;
  15.     printf("\nThe threshold you have entered is valid. \n");
  16.     }
  17.  
  18.     else
  19.     {
  20.     Threshold = 0;
  21.     printf("\nThe threshold you have entered is not valid. \n");
  22.     }
  23.     return Threshold;
  24. }
  25.  
  26. char FinalGradeOutput(char FinalGrade, int InputScore, int A, int B, int C, bool VaildInputCheck)
  27. {
  28.     if (VaildInputCheck == 0)
  29.     FinalGrade = 'N';
  30.  
  31.     else
  32.     {
  33.         if(InputScore >= A)
  34.         FinalGrade = 'A';
  35.  
  36.         else if (InputScore >= B && InputScore < A)
  37.         FinalGrade = 'B';
  38.  
  39.         else if (InputScore >= C && InputScore < B)
  40.         FinalGrade = 'C';
  41.  
  42.         else if (InputScore < C)
  43.             FinalGrade = 'F';
  44.     }
  45.     return FinalGrade;
  46. }
  47.  
  48.     int main()
  49. {
  50.     char FinalGrade;
  51.     int InputScore, A, B, C;
  52.     bool Threshold;
  53.     Threshold = 0;
  54.  
  55.     //Obtaining the values of the threshhold to determine if valid
  56.     printf("\nEnter the threshold for grade A: ");
  57.     scanf("%d", &A);
  58.  
  59.     printf("\nEnter the threshold for grade B: ");
  60.     scanf("%d", &B);
  61.  
  62.     printf("\nEnter the threshold for grade C: ");
  63.     scanf("%d", &C);
  64.  
  65.     printf("\nEnter the student grade: ");
  66.     scanf("%d", &InputScore);
  67.  
  68.     //Function evaluates inputs to determine the grade and validity of previous value
  69.     bool valid = VaildInputCheck(Threshold, A,B,C);
  70.     //FinalGrade = FinalGradeOutput(FinalGrade, InputScore, A, B, C, valid);
  71.     printf("\nYour final grade is: %c \n", FinalGradeOutput(FinalGrade, InputScore, A, B, C, valid));
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement