Advertisement
desislava_topuzakova

08. Graduation

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