nikolayneykov

Untitled

Oct 9th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Exam_Preparation
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int badGradeLimit = int.Parse(Console.ReadLine());
  14. int badGradeCount = 0;
  15. double problemCount = 0;
  16. double gradeSum = 0;
  17. string problemName = string.Empty;
  18. string lastProblemName = string.Empty;
  19.  
  20.  
  21.  
  22. while (badGradeCount < badGradeLimit)
  23. {
  24. problemName = Console.ReadLine();
  25. if (problemName == "Enough")
  26. {
  27. break;
  28. }
  29. double grade = int.Parse(Console.ReadLine());
  30. gradeSum += grade;
  31.  
  32. if (grade > 4)
  33. {
  34. lastProblemName = problemName;
  35. }
  36. else
  37. {
  38. badGradeCount++;
  39. }
  40. problemCount++;
  41. }
  42.  
  43. if (badGradeCount < badGradeLimit && lastProblemName != "Enough")
  44. {
  45. Console.WriteLine($"Average score: {(gradeSum) / problemCount:f2}");
  46. Console.WriteLine($"Number of problems: {problemCount}");
  47. Console.WriteLine($"Last problem: {lastProblemName}");
  48. }
  49. if (badGradeCount == badGradeLimit)
  50. {
  51. Console.WriteLine($"You need a break, {badGradeLimit} poor grades.");
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment