desislava_topuzakova

08. Graduation

Feb 5th, 2022
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8. string student;
  9. cin >> student;
  10.  
  11. int grades = 1;
  12. int fail = 0;
  13. double totalgrade = 0;
  14.  
  15. while(grades <=12)
  16. {
  17. double grade;
  18. cin >> grade;
  19. if (grade >= 4.00)
  20. {
  21. totalgrade += grade;
  22. grades++;
  23. }
  24. else
  25. {
  26. fail++;
  27. }
  28.  
  29. if (fail >= 2)
  30. {
  31. cout << student << " has been excluded at " << grades << " grade" <<endl;
  32. break;
  33. }
  34. }
  35. double averagegrade = totalgrade / 12;
  36.  
  37.  
  38. if (grades >= 12)
  39. {
  40. cout.precision(2);
  41. cout << fixed << student << " graduated. Average grade: " << averagegrade << endl;
  42. }
  43.  
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment