Advertisement
bullit3189

Exam Preparation

Nov 10th, 2018
1,230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 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 _03ExamPreparation
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int numBadGrades = int.Parse(Console.ReadLine());
  14.  
  15. double sumGrades = 0;
  16. int problems = 0;
  17. string lastProblem = string.Empty;
  18. int badGradesCounter = 0;
  19. string currProblem = Console.ReadLine();
  20.  
  21. while (currProblem != "Enough")
  22. {
  23. lastProblem = currProblem;
  24. double currGrade = double.Parse(Console.ReadLine());
  25.  
  26. sumGrades += currGrade;
  27. problems++;
  28.  
  29. if (currGrade<=4.00)
  30. {
  31. badGradesCounter++;
  32. }
  33. if (badGradesCounter == numBadGrades)
  34. {
  35. Console.WriteLine("You need a break, {0} poor grades.",badGradesCounter);
  36. return;
  37. }
  38. currProblem = Console.ReadLine();
  39. }
  40. Console.WriteLine("Average score: {0:f2}",sumGrades/problems);
  41. Console.WriteLine("Number of problems: {0}",problems);
  42. Console.WriteLine("Last problem: {0}",lastProblem);
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement