Advertisement
Alexander_B

Graduation pt.2

Feb 9th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 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 DomashnoGraduationPt2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int numberOfInputs = 1;
  14. double gradeAcumulate = 0.00;
  15. int excludedAcumulate = 0;
  16.  
  17. string name = Console.ReadLine();
  18.  
  19. while (numberOfInputs <= 12 && excludedAcumulate < 2)
  20. {
  21. double grade = double.Parse(Console.ReadLine());
  22. if (grade >= 4.00)
  23. {
  24. gradeAcumulate += grade;
  25. numberOfInputs++;
  26. }
  27. else
  28. {
  29. excludedAcumulate += 1;
  30. }
  31. }
  32.  
  33. if (excludedAcumulate < 2)
  34. {
  35. double averageGrade = 1.00 * gradeAcumulate / (numberOfInputs - 1);
  36. Console.WriteLine($"{name} graduated. Average grade: {averageGrade:f2}");
  37. }
  38. else
  39. {
  40. int gradeExcluded = numberOfInputs;
  41. Console.WriteLine($"{name} has been excluded at {gradeExcluded} grade");
  42. }
  43.  
  44. }
  45.  
  46.  
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement