Advertisement
VickSuna

Untitled

Mar 7th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _09._Graduation_pt._2
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string studentsName = Console.ReadLine();
  10.  
  11. int counterGrades = 1;
  12.  
  13. int fails = 0;
  14.  
  15. double sumGrades = 0;
  16.  
  17. while (counterGrades <= 12)
  18. {
  19. double currentGrade = double.Parse(Console.ReadLine());
  20. if (currentGrade < 4.00)
  21. {
  22. fails++;
  23. }
  24. else if (currentGrade >= 4.00)
  25. {
  26. sumGrades += currentGrade;
  27. counterGrades++;
  28. }
  29.  
  30. if (fails == 2)
  31. {
  32. Console.WriteLine($"{studentsName} has been excluded at {counterGrades} grade");
  33. break;
  34. }
  35. }
  36.  
  37. double averageGrade = sumGrades / 12;
  38.  
  39. if (fails < 2)
  40. {
  41. Console.WriteLine($"{studentsName} graduated. Average grade: {averageGrade:F2}");
  42. }
  43.  
  44.  
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement