petarkobakov

Loops part 2. Graduation

Feb 11th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Graduation
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string name = Console.ReadLine();
  10. double grades = 1;
  11. double sum = 0;
  12.  
  13. while (grades <= 12)
  14. {
  15. double grade = double.Parse(Console.ReadLine());
  16.  
  17. if (grade >= 4.00)
  18. {
  19. sum += grade;
  20. grades++;
  21. }
  22. }
  23. double average = sum / 12;
  24. Console.WriteLine($"{name} graduated. Average grade: {average:F2}");
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment