aggressiveviking

Untitled

Feb 10th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02.ExamPreparation
  4. {
  5. class ExamPreparation
  6. {
  7. static void Main(string[] args)
  8. {
  9. int failedThreshold = int.Parse(Console.ReadLine());
  10.  
  11. int failedTimes = 0;
  12. int solvedProblemsCount = 0;
  13. double gradeSum = 0;
  14. string lastProblem = "";
  15. bool isFailed = true;
  16.  
  17. while (failedTimes < failedThreshold)
  18. {
  19. string problemName = Console.ReadLine();
  20.  
  21. if ("Enough" == problemName)
  22. {
  23. isFailed = false;
  24. break;
  25. }
  26.  
  27. int grade = int.Parse(Console.ReadLine());
  28.  
  29. if (grade <= 4)
  30. {
  31. failedTimes++;
  32. }
  33.  
  34. gradeSum += grade;
  35. solvedProblemsCount++;
  36. lastProblem = problemName;
  37. }
  38.  
  39. if (isFailed)
  40. {
  41. Console.WriteLine($"You need a break, {failedThreshold} poor grades.");
  42. }
  43. else
  44. {
  45. double avg = gradeSum / solvedProblemsCount;
  46.  
  47. Console.WriteLine($"Average score: {avg:f2}");
  48. Console.WriteLine($"Number of problems: {solvedProblemsCount}");
  49. Console.WriteLine($"Last problem: {lastProblem}");
  50. }
  51.  
  52. }
  53. }
  54. }
Add Comment
Please, Sign In to add comment