Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp5
  4. {
  5. class Program
  6. {
  7. public const double GoodGrade = 4.0;
  8. static void Main(string[] args)
  9. {
  10. string input = Console.ReadLine();
  11.  
  12. while (input != "END")
  13. {
  14. double sum = 0;
  15. Boolean failed = false;
  16. for (int i = 1; i <= 12; i++)
  17. {
  18. double grade = double.Parse(Console.ReadLine());
  19.  
  20. if (grade < GoodGrade)
  21. {
  22. if (failed)
  23. {
  24. Console.WriteLine
  25. ($"{input} has been excluded at {i} grade");
  26. break;
  27. }
  28. failed = true;
  29. i--;
  30. }
  31. else
  32. {
  33. failed = false;
  34. sum += grade;
  35. }
  36. }
  37. if (failed)
  38. {
  39. input = Console.ReadLine();
  40. }
  41. else
  42. {
  43. double total = sum / 12;
  44. Console.WriteLine($"{input} graduated. Average grade: {total:f2}");
  45. input = Console.ReadLine();
  46. }
  47.  
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement