simonakancheva

ExamPreparation

Apr 7th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02.Exam_Preparation
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. int unsatisfactoryGrades = int.Parse(Console.ReadLine());
  10. string command = Console.ReadLine();
  11.  
  12. int currentNumberUnsatisfactoryАssessments = 0;
  13. int numberOfProblems = 0;
  14. string lastProblem = string.Empty;
  15. double sum = 0;
  16.  
  17. bool isEnough = true;
  18. while (command != "Enough")
  19. {
  20. numberOfProblems++;
  21. string nameTask = command;
  22. lastProblem = nameTask;
  23.  
  24. int grade = int.Parse(Console.ReadLine());
  25. sum += grade;
  26. if (grade <= 4)
  27. {
  28. currentNumberUnsatisfactoryАssessments++;
  29. }
  30.  
  31. if (currentNumberUnsatisfactoryАssessments == unsatisfactoryGrades)
  32. {
  33. isEnough = false;
  34. break;
  35. }
  36. command = Console.ReadLine();
  37. }
  38.  
  39. if (isEnough)
  40. {
  41. Console.WriteLine($"Average score: {sum / numberOfProblems:f2}");
  42. Console.WriteLine($"Number of problems: {numberOfProblems}");
  43. Console.WriteLine($"Last problem: {lastProblem}");
  44. }
  45. else
  46. {
  47. Console.WriteLine($"You need a break, {unsatisfactoryGrades} poor grades.");
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment